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

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

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

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

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

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

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