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

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

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

e = A("e")
l = B("l")
c = C("c")
m = C("m")
a = B("a")
g = B("g")
i = B("i")

e.t = m
l.o = a
l.p = m
l.s = c
c.x = g
m.x = l
a.o = i
a.p = m
a.s = c
g.o = i
g.p = m
g.s = m
i.o = a
i.p = m
i.s = c
assert i.p.x.o.p.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
c = C("c")
m = C("m")
a = B("a")
g = B("g")
i = B("i")

e.t = m
l.o = a
l.p = m
l.s = c
c.x = g
m.x = l
a.o = i
a.p = m
a.s = c
g.o = i
g.p = m
g.s = m
i.o = a
i.p = m
i.s = c
assert i.p.x.o.p.x.p.x.txt == "l"