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