Rosetta Problems

魔法の糸

https://hoj.hamako-ths.ed.jp/onlinejudge/problems/514