http://codeforces.com/contest/456/problem/B