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

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

c = A("c")
e = B("e")
g = B("g")
d = A("d")

c.u = d
e.t = c
g.t = d
d.u = c
assert d.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.t: A = None
        self.txt = txt

c = A("c")
e = B("e")
g = B("g")
d = A("d")

c.u = d
e.t = c
g.t = d
d.u = c
assert d.u.u.u.u.txt == "d"