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

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

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

f = A("f")
b = B("b")
e = C("e")
j = B("j")

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

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

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

f = A("f")
b = B("b")
e = C("e")
j = B("j")

f.s = j
b.x = j
b.t = e
e.s = f
j.x = b
j.t = e
assert f.s.t.s.txt == "f"