Google Code Jam-MagicTrick