SPOJ 15560: Help the old King