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