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

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

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

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

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

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