I have been trying this question to solve with MO's algorithm. but My solution was getting TLE. Please somebody atleast share an approach, if it is possible to solve with MO's algorithm . Link to problem : http://mirror.codeforces.com/contest/588/problem/E