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