Problem Solved on SPOJ