https://medium.com/@eyajamuehaque/2009c-the-legend-of-freya-the-frog-codeforces-solution-in-c-7519d63f7292