https://codeforces.com/contest/1360/problem/F