Rosetta Problems

K-th beautiful Necklace

https://atcoder.jp/contests/abc252/tasks/abc252_h