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