Rosetta Problems

Kenus the Ancient Greek

https://atcoder.jp/contests/agc015/tasks/agc015_f