Rosetta Problems

RABGAME - Hard version

https://oj.vnoi.info/problem/rabgame1