I am getting WA
I think this problem should be solving by finding grundy number for each row, then applying nim on them as if they are piles size.
I could not code efficient grundy, so through small brute force, i thought grundy of row will be equal to:
sum of powers for all prime numbers in a row. So if row has {4, 12} then {2^2, 2^2*3^1} then pile size = 2+2+1
any hints, and if this pile size is correct that way, why?
Sleep enough after death, it is the time to work.
Mostafa Saad