Rosetta Problems

Periodic Chase

https://atcoder.jp/contests/awc0079/tasks/awc0079_c