My solution for Problem A in the Qualification Round for Google Code Jam 2013