https://codeforces.com/contest/987/problem/B