https://codeforces.com/contest/231/submission/84704319