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

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

f = A("f")
l = B("l")
n = A("n")

f.t = n
l.u = f
n.t = f
assert f.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

f = A("f")
l = B("l")
n = A("n")

f.t = n
l.u = f
n.t = f
assert f.t.t.t.txt == "n"