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

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

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

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

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

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

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

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

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