https://codeforces.com/contest/1546/submission/147704204