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

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

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

l = A("l")
n = B("n")
b = C("b")
h = C("h")
a = A("a")
c = C("c")
f = C("f")
i = B("i")
j = C("j")
g = C("g")

l.p = h
l.q = c
n.s = f
b.s = l
b.o = i
h.s = a
h.o = n
a.p = f
a.q = h
c.s = l
c.o = n
f.s = l
f.o = n
i.s = h
j.s = l
j.o = i
g.s = l
g.o = i
assert i.s.s.q.s.q.s.p.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: C = None
        self.txt = txt

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

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

l = A("l")
n = B("n")
b = C("b")
h = C("h")
a = A("a")
c = C("c")
f = C("f")
i = B("i")
j = C("j")
g = C("g")

l.p = h
l.q = c
n.s = f
b.s = l
b.o = i
h.s = a
h.o = n
a.p = f
a.q = h
c.s = l
c.o = n
f.s = l
f.o = n
i.s = h
j.s = l
j.o = i
g.s = l
g.o = i
assert i.s.s.q.s.q.s.p.o.s.o.txt == "n"