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

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

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

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

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

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

a.x = k
a.s = k
l.o = n
e.x = a
e.s = j
i.o = a
j.x = e
j.s = n
k.x = a
k.s = j
n.x = a
n.s = k
assert i.o.s.s.s.txt == "n"