https://codeforces.com/contest/1430/submission/98839257