Strassen algorithm not fast enough for RRFRNDS

Reading the editorial for RRFRNDS problem from COOK48 it describes a method to solve the problem using Strassen algorithm, but mine solution using is TLE, may someone help me?

RRFRNDS editorial

If someone have ideas to optimize this in python it would be great!
python implementation of Strassen algorithm

Also I saw some posts asking for references of the Strassen algorithm, this implementation + wikipedia is enough to understand it.

!!EDIT

Apparently it isn’t fast enough in c++ either c++ implementation of Strassen algorithm

did anybody solve this problem using Strassen algorithm?