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

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

i = A("i")
d = B("d")
e = B("e")
l = B("l")
c = A("c")
h = B("h")
n = B("n")
m = B("m")
g = B("g")
a = A("a")

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

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

i = A("i")
d = B("d")
e = B("e")
l = B("l")
c = A("c")
h = B("h")
n = B("n")
m = B("m")
g = B("g")
a = A("a")

i.u = l
d.z = e
e.z = n
l.z = h
c.u = d
h.z = n
n.z = d
m.z = n
g.z = h
a.u = d
assert e.z.z.z.txt == "e"