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

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: D = None
        self.y: B = None
        self.t: A = None
        self.txt = txt

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

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

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

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

d.z = l
n.o = g
n.r = k
n.y = m
n.t = l
g.z = k
g.x = l
a.t = e
f.o = g
f.q = g
f.s = m
m.o = g
m.r = i
m.y = n
m.t = d
e.t = a
l.z = d
i.t = k
k.t = e
assert k.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: D = None
        self.y: B = None
        self.t: A = None
        self.txt = txt

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

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

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

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

d.z = l
n.o = g
n.r = k
n.y = m
n.t = l
g.z = k
g.x = l
a.t = e
f.o = g
f.q = g
f.s = m
m.o = g
m.r = i
m.y = n
m.t = d
e.t = a
l.z = d
i.t = k
k.t = e
assert k.t.t.t.t.t.txt == "e"