Rosetta Problems

Chain Pass of Balls

https://atcoder.jp/contests/awc0144/tasks/awc0144_e