Solution for Phi 2012 task