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

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

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

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

n.z = k
n.v = f
n.w = f
f.t = n
k.z = f
assert f.t.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

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

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

n.z = k
n.v = f
n.w = f
f.t = n
k.z = f
assert f.t.z.z.txt == "f"