SPOJ 59 in progress