I was trying to solve 25E, I used hash and passed it, this is my submission. There is also a similar problem in SPOJ, link. The difference is only that the problem in SPOJ has $$$T$$$ test cases, where codeforces has only one.
I clear for every test, but got wrong answer in SPOJ. Is my algorithm wrong or there is some corner cases i didn't realize? Thanks.