http://www.e-olimp.com/ua/problems/37
http://www.e-olimp.com/ua/problems/37