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

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

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

n = A("n")
i = B("i")
j = C("j")
m = C("m")
g = C("g")
k = A("k")
l = B("l")
b = A("b")
e = C("e")

n.o = i
i.y = k
j.p = b
j.y = l
m.p = k
m.y = i
g.p = b
g.y = l
k.o = i
l.y = k
b.o = i
e.p = k
e.y = l
assert l.y.o.y.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

n = A("n")
i = B("i")
j = C("j")
m = C("m")
g = C("g")
k = A("k")
l = B("l")
b = A("b")
e = C("e")

n.o = i
i.y = k
j.p = b
j.y = l
m.p = k
m.y = i
g.p = b
g.y = l
k.o = i
l.y = k
b.o = i
e.p = k
e.y = l
assert l.y.o.y.o.y.o.txt == "i"