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

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

l = A("l")
e = B("e")
m = A("m")
i = B("i")
a = A("a")
c = A("c")
n = B("n")
k = A("k")
f = B("f")

l.s = n
e.q = f
m.s = i
i.q = f
a.s = e
c.s = i
n.q = i
k.s = n
f.q = i
assert i.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

l = A("l")
e = B("e")
m = A("m")
i = B("i")
a = A("a")
c = A("c")
n = B("n")
k = A("k")
f = B("f")

l.s = n
e.q = f
m.s = i
i.q = f
a.s = e
c.s = i
n.q = i
k.s = n
f.q = i
assert i.q.q.q.q.q.q.txt == "i"