Problem in prob. similar to NIM

Problem link: https://www.hackerearth.com/problem/algorithm/jon-and-ramsay-60/description/
Code Link: https://ide.codingblocks.com/s/53599

We don’t include solving doubts which are not related to hackerblock or coding blocks material as everyone can post any question from any platform. You can try solving all the game theory questions from Hackerblock platform