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

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

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

j = A("j")
f = B("f")
m = C("m")

j.v = f
j.z = f
j.p = f
f.w = j
f.p = j
m.z = j
m.q = j
assert m.z.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
m = C("m")

j.v = f
j.z = f
j.p = f
f.w = j
f.p = j
m.z = j
m.q = j
assert m.z.v.w.txt == "j"