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

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

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

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

c.v = k
c.y = f
k.v = f
k.s = c
f.z = k
f.p = k
f.t = c
assert c.y.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: C = None
        self.txt = txt

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

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

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

c.v = k
c.y = f
k.v = f
k.s = c
f.z = k
f.p = k
f.t = c
assert c.y.p.s.txt == "c"