I am trying to solve this problem. I am checking from a given state, which subsets we can go to and finding sprague-grundy function. When I am printing the functions, I am getting wrong answer. It is correct for first sample test, but for the second one, it is incorrect.

p.s. I changed the last few lines in solve function (for variable ans), but I think last one wasn’t incorrect as well