GSoC2013 Qualification Test: xndcn

This is my answer.
Tested OK.