SPOJ: KOZE Solved.