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

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

l = A("l")
c = B("c")
f = B("f")
k = A("k")

l.t = k
c.x = k
f.x = l
k.t = l
assert l.t.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.x: A = None
        self.txt = txt

l = A("l")
c = B("c")
f = B("f")
k = A("k")

l.t = k
c.x = k
f.x = l
k.t = l
assert l.t.t.t.t.txt == "l"