https://www.facebook.com/hackercup/problems.php?round=146094915502528 Solutions: https://www.facebook.com/notes/facebook-hacker-cup/2012-qualification-round-solutions/371108282905079