Help in predicting the winner question

Hello.
Can anyone please tell how to approach questions like this -> https://www.codechef.com/problems/BUDDYNIM
Thanks in advance.