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

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

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

m.u = a
e.u = m
f.u = m
b.u = m
a.u = m
h.u = m
assert m.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

m.u = a
e.u = m
f.u = m
b.u = m
a.u = m
h.u = m
assert m.u.u.u.txt == "a"