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

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

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

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

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

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

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

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

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

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

k.z = n
k.r = g
n.s = i
n.v = i
n.p = i
n.z = k
e.z = i
e.p = g
l.u = e
l.r = i
i.s = n
i.v = n
i.p = n
i.z = k
m.z = n
m.p = g
g.u = m
g.r = i
a.u = m
a.r = n
assert a.r.s.z.txt == "k"