Rosetta Problems

Grafting

https://atcoder.jp/contests/agc027/tasks/agc027_f