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

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

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

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

l = A("l")
j = B("j")
k = C("k")
i = D("i")
d = C("d")
g = C("g")
f = B("f")
h = D("h")
c = B("c")
e = A("e")

l.z = f
j.z = i
k.y = f
i.u = l
d.y = f
g.y = f
f.z = i
h.u = e
c.z = h
e.z = j
assert d.y.z.u.z.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
k = C("k")
i = D("i")
d = C("d")
g = C("g")
f = B("f")
h = D("h")
c = B("c")
e = A("e")

l.z = f
j.z = i
k.y = f
i.u = l
d.y = f
g.y = f
f.z = i
h.u = e
c.z = h
e.z = j
assert d.y.z.u.z.z.u.z.txt == "f"