Help to debug

I am trying to solve this problem on spoj. I used ETT with Mo’s algorithm but my code is giving TLE and i cannot figure out why. Any help will be appreciated.

Code link - GHJSa0 - Online C++0x Compiler & Debugging Tool - Ideone.com

It can’t be reached. please give the correct link.

Both links are working fine bro.