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

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

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

f = A("f")
n = B("n")
e = C("e")

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

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

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

f = A("f")
n = B("n")
e = C("e")

f.z = e
f.t = n
n.x = f
e.s = n
assert f.z.s.x.txt == "f"