Points on a Segment

Count how many of N distinct points fall inside each of M closed intervals on a line.

Medium4Binary searchSortingInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

A one dimensional coordinate line holds N points and M segments. For each segment, count how many of the given points lie on it.

A segment includes both of its endpoints, so a point at coordinate xx lies on the segment [a,b][a, b] when axba \le x \le b.

Input

The first line contains the number of points NN and the number of segments MM (1N,M1000001 \le N, M \le 100000).

The second line contains the coordinates of the NN points. No two points share a coordinate.

Each of the next MM lines contains the start and the end of one segment. The start is less than or equal to the end.

Every coordinate in the input is a natural number not greater than 10910^9.

Output

For each segment, in input order, print on its own line how many of the given points lie on it.