class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

m.r = k
n.z = c
h.u = a
a.u = n
a.w = l
g.r = h
f.r = h
i.r = h
c.z = n
l.r = h
k.u = a
assert i.r.u.u.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

m.r = k
n.z = c
h.u = a
a.u = n
a.w = l
g.r = h
f.r = h
i.r = h
c.z = n
l.r = h
k.u = a
assert i.r.u.u.z.z.z.txt == "c"