Codeforces Solution