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

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

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

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

b = A("b")
m = B("m")
a = C("a")
n = D("n")

b.w = m
m.z = a
m.r = a
m.u = n
m.s = n
a.z = n
n.x = a
n.y = a
n.r = a
n.w = b
assert n.w.w.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
a = C("a")
n = D("n")

b.w = m
m.z = a
m.r = a
m.u = n
m.s = n
a.z = n
n.x = a
n.y = a
n.r = a
n.w = b
assert n.w.w.r.z.txt == "n"