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

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

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

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

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

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

l.s = n
a.o = f
i.s = l
e.s = l
b.s = e
f.o = a
k.s = l
j.s = c
c.s = j
n.s = b
assert e.s.s.s.s.s.txt == "l"