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

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

l = A("l")
k = B("k")
f = A("f")
n = A("n")
i = B("i")
g = B("g")

l.s = i
l.y = k
k.s = g
k.x = g
f.s = i
f.y = g
n.s = i
n.y = g
i.s = g
i.x = g
g.s = i
g.x = k
assert f.s.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.txt = txt

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

l = A("l")
k = B("k")
f = A("f")
n = A("n")
i = B("i")
g = B("g")

l.s = i
l.y = k
k.s = g
k.x = g
f.s = i
f.y = g
n.s = i
n.y = g
i.s = g
i.x = g
g.s = i
g.x = k
assert f.s.x.x.x.x.txt == "k"