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

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

h = A("h")
i = B("i")
e = A("e")
d = A("d")
m = B("m")

h.t = i
i.u = m
e.t = m
d.t = m
m.u = i
assert e.t.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

h = A("h")
i = B("i")
e = A("e")
d = A("d")
m = B("m")

h.t = i
i.u = m
e.t = m
d.t = m
m.u = i
assert e.t.u.u.u.u.txt == "m"