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

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

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

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

l.p = e
l.o = m
n.o = l
n.s = e
m.p = j
e.o = l
e.s = n
j.p = e
j.o = c
g.p = j
i.o = l
i.s = e
c.p = j
h.p = l
assert c.p.p.o.p.s.o.p.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: C = None
        self.txt = txt

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

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

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

l.p = e
l.o = m
n.o = l
n.s = e
m.p = j
e.o = l
e.s = n
j.p = e
j.o = c
g.p = j
i.o = l
i.s = e
c.p = j
h.p = l
assert c.p.p.o.p.s.o.p.s.o.txt == "l"