The input data can have up to a million digits. When it overflows int, your program encounters problems. You need to figure out how to solve the problem by working with strings.
And, besides that, the program doesn't print a newline after each case.
If you have questions about how to solve or debug a particular problem, you should post in the ProblemSet Archive section of the forum. This forum is for language-specific discussion.