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

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

k = A("k")
f = B("f")
b = B("b")
j = A("j")
i = B("i")
a = B("a")
m = B("m")
l = B("l")

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

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

k = A("k")
f = B("f")
b = B("b")
j = A("j")
i = B("i")
a = B("a")
m = B("m")
l = B("l")

k.s = a
k.o = l
f.s = k
b.s = j
j.s = l
j.o = a
i.s = j
a.s = j
m.s = j
l.s = j
assert m.s.s.s.o.txt == "a"