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

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

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

h = A("h")
a = B("a")
b = C("b")

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

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

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

h = A("h")
a = B("a")
b = C("b")

h.t = b
h.x = b
h.v = a
a.z = h
b.o = h
b.y = h
b.p = a
assert a.z.v.z.txt == "h"