"Shifting trees" from Codejam 2012