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

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

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

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

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

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

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

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

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

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

a.z = e
a.p = i
a.x = k
a.w = b
k.z = g
k.r = a
k.p = n
g.t = b
g.p = b
g.w = e
g.u = d
l.r = n
n.r = l
i.z = e
i.x = e
i.p = a
i.w = g
d.z = g
d.r = i
d.p = l
b.t = g
b.p = g
b.w = k
b.u = d
e.z = g
e.r = i
e.p = l
assert n.r.r.r.r.r.r.r.r.txt == "n"