Rosetta Problems

ほもの君と木と無限ループと

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