Rosetta Problems

NMパズル

https://atcoder.jp/contests/njpc2017/tasks/njpc2017_d