class A:
    def __init__(self, txt: str):
        self.v: B = 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.q: C = None
        self.o: C = None
        self.txt = txt

n = A("n")
a = B("a")
h = C("h")
e = C("e")
j = A("j")
g = C("g")
c = B("c")
m = C("m")
l = B("l")

n.v = c
a.p = l
h.q = m
h.o = e
e.q = m
e.o = g
j.v = c
g.q = e
g.o = h
c.p = a
m.q = h
m.o = h
l.p = a
assert m.q.q.o.o.o.q.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = 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.q: C = None
        self.o: C = None
        self.txt = txt

n = A("n")
a = B("a")
h = C("h")
e = C("e")
j = A("j")
g = C("g")
c = B("c")
m = C("m")
l = B("l")

n.v = c
a.p = l
h.q = m
h.o = e
e.q = m
e.o = g
j.v = c
g.q = e
g.o = h
c.p = a
m.q = h
m.o = h
l.p = a
assert m.q.q.o.o.o.q.q.o.q.txt == "m"