Addming 7107 - G Key from SPOJ, what a tedious problem, but it's really nice one