class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: E = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: D = None
        self.txt = txt

j = A("j")
m = B("m")
g = C("g")
b = D("b")
h = E("h")

j.o = b
m.p = b
g.q = b
g.u = h
g.x = m
b.s = m
b.w = m
h.o = m
h.w = b
assert j.o.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: E = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: D = None
        self.txt = txt

j = A("j")
m = B("m")
g = C("g")
b = D("b")
h = E("h")

j.o = b
m.p = b
g.q = b
g.u = h
g.x = m
b.s = m
b.w = m
h.o = m
h.w = b
assert j.o.s.p.s.txt == "m"