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

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

l = A("l")
b = B("b")
f = A("f")
a = A("a")
c = A("c")

l.x = b
b.t = a
b.r = c
f.x = b
a.x = b
c.x = b
assert b.t.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
f = A("f")
a = A("a")
c = A("c")

l.x = b
b.t = a
b.r = c
f.x = b
a.x = b
c.x = b
assert b.t.x.r.x.txt == "b"