Sort queries by:
Primary: block of left endpoint ()
Secondary: right endpoint () Within the same block of , right endpoints are sorted. So only increases (or decreases after a block change), limiting movement. Across all queries in one -block, moves at most positions total. There are blocks, so total movement is . The pointer moves at most within a block, and there are queries, so total movement is . Combined: .