Rosetta Problems

We Used to Sing a Song Together(★3)

https://atcoder.jp/contests/typical90/tasks/typical90_n