Ilya and tic-tac-toe game

CodeForces - 754B