solved 2014 round 1a a large practice.
reference google codejan analysis