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

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

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

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

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

n.u = i
h.u = n
i.u = n
m.u = i
assert i.u.u.u.u.txt == "i"