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

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

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

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

g = A("g")
f = B("f")
i = C("i")
j = D("j")
c = D("c")
h = A("h")
e = A("e")
l = A("l")
n = C("n")
m = B("m")

g.p = e
f.r = h
f.o = m
i.z = n
i.t = n
i.w = l
i.y = c
j.z = i
j.q = f
j.x = c
c.z = i
c.q = m
c.x = j
h.p = e
e.p = l
l.p = e
n.z = i
n.t = i
n.w = e
n.y = c
m.r = l
m.o = f
assert e.p.p.p.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.r: A = None
        self.o: B = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
i = C("i")
j = D("j")
c = D("c")
h = A("h")
e = A("e")
l = A("l")
n = C("n")
m = B("m")

g.p = e
f.r = h
f.o = m
i.z = n
i.t = n
i.w = l
i.y = c
j.z = i
j.q = f
j.x = c
c.z = i
c.q = m
c.x = j
h.p = e
e.p = l
l.p = e
n.z = i
n.t = i
n.w = e
n.y = c
m.r = l
m.o = f
assert e.p.p.p.p.p.p.p.p.p.p.txt == "e"