Rosetta Problems

Where is the Boundary

https://atcoder.jp/contests/jag2015summer-day4/tasks/icpc2015summer_day4_a