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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: A = None
        self.txt = txt

k = A("k")
m = B("m")
a = C("a")
c = D("c")
e = D("e")
n = A("n")
d = B("d")
l = B("l")
i = A("i")

k.z = m
k.t = i
k.u = c
m.s = a
a.p = l
a.w = c
c.v = i
c.r = n
e.v = n
e.r = k
n.z = d
n.t = k
n.u = e
d.s = a
l.s = a
i.z = m
i.t = k
i.u = e
assert m.s.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: A = None
        self.u: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: A = None
        self.txt = txt

k = A("k")
m = B("m")
a = C("a")
c = D("c")
e = D("e")
n = A("n")
d = B("d")
l = B("l")
i = A("i")

k.z = m
k.t = i
k.u = c
m.s = a
a.p = l
a.w = c
c.v = i
c.r = n
e.v = n
e.r = k
n.z = d
n.t = k
n.u = e
d.s = a
l.s = a
i.z = m
i.t = k
i.u = e
assert m.s.p.s.p.s.txt == "a"