https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=609&page=show_problem&problem=2502
I could’nt think of any solution for this either than writing all the possible moves. Can anyone help me with it?