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

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

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

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

g = A("g")
e = B("e")
j = C("j")
c = D("c")
a = D("a")
d = D("d")
m = C("m")
n = B("n")
i = B("i")

g.o = m
g.t = i
g.q = a
g.p = a
e.p = i
j.y = e
c.q = j
c.s = j
c.y = i
c.p = g
a.q = j
a.s = j
a.y = e
a.p = g
d.q = j
d.y = e
d.p = g
d.s = m
m.y = e
n.p = e
i.p = e
assert m.y.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: B = None
        self.q: D = None
        self.p: D = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
j = C("j")
c = D("c")
a = D("a")
d = D("d")
m = C("m")
n = B("n")
i = B("i")

g.o = m
g.t = i
g.q = a
g.p = a
e.p = i
j.y = e
c.q = j
c.s = j
c.y = i
c.p = g
a.q = j
a.s = j
a.y = e
a.p = g
d.q = j
d.y = e
d.p = g
d.s = m
m.y = e
n.p = e
i.p = e
assert m.y.p.p.p.p.p.p.p.p.txt == "e"