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

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

k = A("k")
i = B("i")
l = A("l")
j = B("j")
g = A("g")
e = A("e")
c = B("c")
d = A("d")
b = A("b")
n = A("n")

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

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

k = A("k")
i = B("i")
l = A("l")
j = B("j")
g = A("g")
e = A("e")
c = B("c")
d = A("d")
b = A("b")
n = A("n")

k.s = i
i.o = l
l.s = j
j.o = b
g.s = i
e.s = c
c.o = e
d.s = j
b.s = i
n.s = i
assert j.o.s.o.s.o.s.txt == "i"