https://vjudge.net/contest/406992#problem/B