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

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

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

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

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

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

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

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

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