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

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

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

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

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

a.s = k
a.z = k
a.x = h
a.p = n
n.t = d
k.r = i
k.x = g
k.s = d
d.z = n
l.s = i
l.x = h
l.z = e
l.p = n
c.s = e
c.x = d
c.z = k
c.p = n
g.s = e
g.z = e
g.x = d
g.p = n
h.z = n
i.r = k
i.x = a
i.s = h
e.r = k
e.x = g
e.s = d
assert l.s.r.s.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: D = None
        self.z: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

a.s = k
a.z = k
a.x = h
a.p = n
n.t = d
k.r = i
k.x = g
k.s = d
d.z = n
l.s = i
l.x = h
l.z = e
l.p = n
c.s = e
c.x = d
c.z = k
c.p = n
g.s = e
g.z = e
g.x = d
g.p = n
h.z = n
i.r = k
i.x = a
i.s = h
e.r = k
e.x = g
e.s = d
assert l.s.r.s.z.t.txt == "d"