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

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

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

m = A("m")
a = B("a")
f = C("f")
e = A("e")
c = B("c")
i = C("i")
j = B("j")
n = C("n")
l = C("l")

m.q = e
m.p = e
a.q = l
a.o = i
a.s = j
f.y = a
f.x = m
e.q = m
e.p = m
c.q = l
c.o = n
c.s = j
i.y = a
i.x = e
j.q = l
j.o = n
j.s = c
n.y = j
n.x = e
l.y = j
l.x = e
assert e.p.p.p.q.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.p: A = None
        self.txt = txt

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

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

m = A("m")
a = B("a")
f = C("f")
e = A("e")
c = B("c")
i = C("i")
j = B("j")
n = C("n")
l = C("l")

m.q = e
m.p = e
a.q = l
a.o = i
a.s = j
f.y = a
f.x = m
e.q = m
e.p = m
c.q = l
c.o = n
c.s = j
i.y = a
i.x = e
j.q = l
j.o = n
j.s = c
n.y = j
n.x = e
l.y = j
l.x = e
assert e.p.p.p.q.p.p.txt == "e"