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

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

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

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

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

i.p = b
i.r = e
i.y = a
d.y = l
d.w = b
b.o = i
b.y = d
b.t = k
b.s = a
l.z = d
a.o = e
a.y = d
a.t = l
a.s = b
m.y = k
m.w = a
k.z = m
e.p = b
e.r = i
e.y = a
assert l.z.w.t.z.y.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: A = None
        self.y: C = None
        self.txt = txt

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

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

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

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

i.p = b
i.r = e
i.y = a
d.y = l
d.w = b
b.o = i
b.y = d
b.t = k
b.s = a
l.z = d
a.o = e
a.y = d
a.t = l
a.s = b
m.y = k
m.w = a
k.z = m
e.p = b
e.r = i
e.y = a
assert l.z.w.t.z.y.z.w.txt == "a"