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

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

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

k = A("k")
a = B("a")
m = C("m")

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

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

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

k = A("k")
a = B("a")
m = C("m")

k.p = a
k.x = m
a.w = k
m.v = k
m.z = a
assert k.p.w.p.txt == "a"