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

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

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

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

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

e.p = l
j.w = d
j.s = m
j.q = k
j.p = a
m.o = e
m.z = k
m.r = n
m.p = c
a.p = n
a.q = n
n.p = a
n.q = a
d.o = l
d.z = j
d.r = h
d.p = m
c.o = e
c.z = k
c.r = a
c.p = m
h.p = n
h.q = a
k.w = d
k.s = c
k.q = j
k.p = a
l.p = e
assert d.z.w.o.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

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

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

e.p = l
j.w = d
j.s = m
j.q = k
j.p = a
m.o = e
m.z = k
m.r = n
m.p = c
a.p = n
a.q = n
n.p = a
n.q = a
d.o = l
d.z = j
d.r = h
d.p = m
c.o = e
c.z = k
c.r = a
c.p = m
h.p = n
h.q = a
k.w = d
k.s = c
k.q = j
k.p = a
l.p = e
assert d.z.w.o.p.p.p.p.p.p.p.txt == "e"