Coded http://community.topcoder.com/stat?c=problem_statement&pm=2998&rd=5857