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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: D = None
        self.s: C = None
        self.o: A = None
        self.txt = txt

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

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

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

n.u = a
n.s = a
n.w = m
m.q = c
m.r = c
m.s = a
m.o = n
a.q = c
c.w = m
c.z = m
assert a.q.w.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: B = None
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: D = None
        self.s: C = None
        self.o: A = None
        self.txt = txt

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

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

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

n.u = a
n.s = a
n.w = m
m.q = c
m.r = c
m.s = a
m.o = n
a.q = c
c.w = m
c.z = m
assert a.q.w.q.z.txt == "m"