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

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

f = A("f")
m = B("m")
d = A("d")
l = A("l")
i = A("i")
k = B("k")
n = B("n")
g = B("g")
e = A("e")

f.u = i
m.z = e
d.u = i
l.u = i
i.u = l
k.z = d
n.z = i
g.z = d
e.u = i
assert d.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

f = A("f")
m = B("m")
d = A("d")
l = A("l")
i = A("i")
k = B("k")
n = B("n")
g = B("g")
e = A("e")

f.u = i
m.z = e
d.u = i
l.u = i
i.u = l
k.z = d
n.z = i
g.z = d
e.u = i
assert d.u.u.u.u.u.u.u.u.txt == "l"