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

b = A("b")
i = B("i")
h = A("h")
m = A("m")
a = B("a")
e = B("e")

b.z = e
i.u = m
h.z = a
m.z = a
a.u = h
e.u = b
assert a.u.z.u.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.u: A = None
        self.txt = txt

b = A("b")
i = B("i")
h = A("h")
m = A("m")
a = B("a")
e = B("e")

b.z = e
i.u = m
h.z = a
m.z = a
a.u = h
e.u = b
assert a.u.z.u.z.u.z.txt == "a"