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

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

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

a.x = k
a.s = k
l.o = a
l.y = k
k.o = a
k.y = l
assert k.y.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.txt = txt

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

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

a.x = k
a.s = k
l.o = a
l.y = k
k.o = a
k.y = l
assert k.y.o.x.txt == "k"