https://codeforces.com/contest/997/submission/78567893