I have been trying to solve the above problem. It is clear to me that above question is to be solved by sprague-grundy theorum, but since I am new to the topic I am not able to break it into independent games and there is also no Editorial available for the given problem.

Thanks for Help!