Solution for Xi 2012 task