Rosetta Problems

Bead Sequence

https://atcoder.jp/contests/awc0126/tasks/awc0126_d