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

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

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

c = A("c")
k = B("k")
b = C("b")
a = A("a")

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

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

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

c = A("c")
k = B("k")
b = C("b")
a = A("a")

c.z = a
c.t = a
c.v = b
k.y = a
k.p = a
k.o = b
b.z = k
b.y = k
a.z = c
a.t = c
a.v = b
assert b.z.p.z.v.txt == "b"