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.y: B = None
        self.txt = txt

k = A("k")
e = B("e")
a = B("a")
f = A("f")
l = B("l")

k.s = e
k.o = l
e.y = l
a.y = l
f.s = a
f.o = a
l.y = a
assert l.y.y.y.y.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.y: B = None
        self.txt = txt

k = A("k")
e = B("e")
a = B("a")
f = A("f")
l = B("l")

k.s = e
k.o = l
e.y = l
a.y = l
f.s = a
f.o = a
l.y = a
assert l.y.y.y.y.txt == "l"