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

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

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

k = A("k")
l = B("l")
i = C("i")
g = A("g")
n = B("n")
a = C("a")
c = C("c")
f = A("f")
m = B("m")

k.q = g
k.p = n
k.o = a
l.y = c
i.p = m
g.q = k
g.p = l
g.o = c
n.y = a
a.p = l
c.p = n
f.q = k
f.p = n
f.o = i
m.y = c
assert n.y.p.y.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.p: B = None
        self.o: C = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
i = C("i")
g = A("g")
n = B("n")
a = C("a")
c = C("c")
f = A("f")
m = B("m")

k.q = g
k.p = n
k.o = a
l.y = c
i.p = m
g.q = k
g.p = l
g.o = c
n.y = a
a.p = l
c.p = n
f.q = k
f.p = n
f.o = i
m.y = c
assert n.y.p.y.p.y.p.txt == "l"