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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: C = None
        self.z: C = None
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: D = None
        self.txt = txt

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

n = A("n")
i = B("i")
f = C("f")
m = D("m")

n.q = i
i.u = m
i.x = f
i.z = f
i.t = f
f.v = m
f.q = m
m.y = f
m.p = f
m.w = f
assert f.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: C = None
        self.z: C = None
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: D = None
        self.txt = txt

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

n = A("n")
i = B("i")
f = C("f")
m = D("m")

n.q = i
i.u = m
i.x = f
i.z = f
i.t = f
f.v = m
f.q = m
m.y = f
m.p = f
m.w = f
assert f.q.w.q.txt == "m"