class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: C = None
        self.z: D = None
        self.o: C = None
        self.w: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: D = None
        self.x: B = None
        self.o: B = None
        self.t: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: A = None
        self.txt = txt

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

m.x = k
m.z = k
m.w = k
m.q = i
m.o = i
f.o = n
f.x = n
f.p = i
f.t = k
i.s = k
i.r = k
i.x = f
i.o = f
i.t = l
k.q = i
l.p = m
l.t = m
n.o = f
n.x = f
n.p = i
n.t = k
assert m.w.q.o.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: C = None
        self.z: D = None
        self.o: C = None
        self.w: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: D = None
        self.x: B = None
        self.o: B = None
        self.t: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: A = None
        self.txt = txt

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

m.x = k
m.z = k
m.w = k
m.q = i
m.o = i
f.o = n
f.x = n
f.p = i
f.t = k
i.s = k
i.r = k
i.x = f
i.o = f
i.t = l
k.q = i
l.p = m
l.t = m
n.o = f
n.x = f
n.p = i
n.t = k
assert m.w.q.o.p.s.txt == "k"