WA in IITKWPCO SPOJ

,

link text

i am getting WA for my solution

link text

can anyone plz tell where i am going wrong or any corner test case that i am missing??

//