Codeforces Round 1107 (Div. 3) Upsolving (finished)