Trinity Codeforces Solution