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

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

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

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

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

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

a.s = f
f.t = b
f.x = b
b.t = f
b.x = f
assert a.s.x.x.txt == "f"