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

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

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

n = A("n")
k = B("k")
h = C("h")
m = A("m")

n.w = k
n.u = k
k.y = h
h.r = k
h.v = k
h.z = m
m.w = k
m.u = k
assert n.w.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: B = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
h = C("h")
m = A("m")

n.w = k
n.u = k
k.y = h
h.r = k
h.v = k
h.z = m
m.w = k
m.u = k
assert n.w.y.z.txt == "m"