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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.r: C = None
        self.txt = txt

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

m = A("m")
b = B("b")
a = C("a")
k = D("k")
h = B("h")
c = C("c")
l = C("l")
i = A("i")
f = C("f")
j = C("j")

m.z = k
b.q = k
b.u = k
a.q = h
a.p = l
a.r = j
k.x = b
h.q = k
h.u = k
c.q = b
c.p = j
c.r = j
l.q = b
l.p = a
l.r = j
i.z = k
f.q = b
f.p = l
f.r = a
j.q = b
j.p = l
j.r = f
assert k.x.q.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.r: C = None
        self.txt = txt

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

m = A("m")
b = B("b")
a = C("a")
k = D("k")
h = B("h")
c = C("c")
l = C("l")
i = A("i")
f = C("f")
j = C("j")

m.z = k
b.q = k
b.u = k
a.q = h
a.p = l
a.r = j
k.x = b
h.q = k
h.u = k
c.q = b
c.p = j
c.r = j
l.q = b
l.p = a
l.r = j
i.z = k
f.q = b
f.p = l
f.r = a
j.q = b
j.p = l
j.r = f
assert k.x.q.x.q.x.txt == "b"