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

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

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

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

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

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

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

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

k.y = b
k.v = b
k.q = h
h.p = k
b.p = k
b.z = k
b.w = a
a.y = b
a.v = b
a.q = h
assert h.p.v.w.txt == "a"