solved a spoj problem