SPOJ problem