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

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

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

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

m = A("m")
d = B("d")
j = C("j")
a = D("a")
f = C("f")
h = B("h")
k = C("k")
e = D("e")
b = D("b")

m.z = h
d.u = m
j.r = e
j.u = h
j.q = a
j.w = m
a.q = h
f.r = b
f.u = d
f.q = a
f.w = m
h.u = m
k.r = e
k.q = e
k.u = h
k.w = m
e.q = d
b.q = d
assert m.z.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

m = A("m")
d = B("d")
j = C("j")
a = D("a")
f = C("f")
h = B("h")
k = C("k")
e = D("e")
b = D("b")

m.z = h
d.u = m
j.r = e
j.u = h
j.q = a
j.w = m
a.q = h
f.r = b
f.u = d
f.q = a
f.w = m
h.u = m
k.r = e
k.q = e
k.u = h
k.w = m
e.q = d
b.q = d
assert m.z.u.z.u.txt == "m"