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

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

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

n = A("n")
c = B("c")
l = C("l")
j = C("j")
i = A("i")
b = B("b")
a = C("a")
e = A("e")

n.s = a
n.q = j
c.r = j
c.q = b
c.s = b
l.q = i
j.q = e
i.s = j
i.q = l
b.r = l
b.q = c
b.s = c
a.q = e
e.s = l
e.q = l
assert a.q.s.q.s.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
l = C("l")
j = C("j")
i = A("i")
b = B("b")
a = C("a")
e = A("e")

n.s = a
n.q = j
c.r = j
c.q = b
c.s = b
l.q = i
j.q = e
i.s = j
i.q = l
b.r = l
b.q = c
b.s = c
a.q = e
e.s = l
e.q = l
assert a.q.s.q.s.q.s.q.txt == "i"