Rosetta Problems

Escape from the Hell

https://atcoder.jp/contests/jag2016autumn/tasks/icpc2016autumn_f