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

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

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

m = A("m")
d = B("d")
b = C("b")

m.w = b
m.z = b
m.y = b
d.u = m
b.v = m
b.t = d
b.p = d
assert b.p.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.z: C = None
        self.y: C = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
b = C("b")

m.w = b
m.z = b
m.y = b
d.u = m
b.v = m
b.t = d
b.p = d
assert b.p.u.z.txt == "b"