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

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

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

e = A("e")
a = B("a")
i = C("i")
m = B("m")
g = C("g")
d = B("d")
j = B("j")
c = A("c")
b = B("b")
n = B("n")

e.s = g
a.o = b
i.y = e
i.p = g
m.o = j
g.y = e
g.p = i
d.o = a
j.o = m
c.s = g
b.o = m
n.o = a
assert b.o.o.o.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

e = A("e")
a = B("a")
i = C("i")
m = B("m")
g = C("g")
d = B("d")
j = B("j")
c = A("c")
b = B("b")
n = B("n")

e.s = g
a.o = b
i.y = e
i.p = g
m.o = j
g.y = e
g.p = i
d.o = a
j.o = m
c.s = g
b.o = m
n.o = a
assert b.o.o.o.o.o.o.o.o.o.o.txt == "j"