Problem - G - Codeforces