Rosetta Problems

Free Contest 28 - MAGICAL3

https://oj.vnoi.info/problem/fc028_magical3