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

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

f = A("f")
g = B("g")
a = B("a")
c = B("c")
l = B("l")
d = A("d")

f.u = d
g.x = l
g.t = f
a.x = c
a.t = d
c.x = l
c.t = f
l.x = c
l.t = f
d.u = f
assert d.u.u.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.x: B = None
        self.t: A = None
        self.txt = txt

f = A("f")
g = B("g")
a = B("a")
c = B("c")
l = B("l")
d = A("d")

f.u = d
g.x = l
g.t = f
a.x = c
a.t = d
c.x = l
c.t = f
l.x = c
l.t = f
d.u = f
assert d.u.u.u.u.u.u.txt == "d"