Solution for Chi 2012 task