Blog: https://codeforces.com/blog/entry/85900
Problems: https://codeforces.com/problemset/problem/1175/F