Updated ICPC 2011 - Magnets solution.