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

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

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

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

m = A("m")
l = B("l")
c = C("c")
e = D("e")

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

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

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

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

m = A("m")
l = B("l")
c = C("c")
e = D("e")

m.o = l
m.u = c
l.z = m
c.w = e
e.s = m
e.u = l
e.q = l
e.x = l
assert e.x.z.o.z.txt == "m"