I have been trying to solve this problem for some time now but have been unable to figure out a way to find the grundy values for rows. I tried writing a bruteforce solution which gives me the grundy values of rows to try to figure out the relation between grundy values and position of stones in a row but have not been able to observe any pattern.
Any hints would be appreciated.