Add solution for 2012 World Final Problem H.