How to solve turn based algorithm (from Hackerrank)


someone help me to solve : https://www.hackerrank.com/contests/moraxtreme-4-0/challenges/sad-meiers-trivilization if someone know the strategy please explain me.