#K16001. Counting Intervals

    ID: 24481 Type: Default 1000ms 256MiB

Counting Intervals

Counting Intervals

You are given n intervals and q queries. Each interval is represented by two integers \(a_i\) and \(b_i\) (with \(a_i \le b_i\)). For each query integer \(x\), determine how many intervals contain \(x\), i.e. count the number of intervals such that \(a_i \le x \le b_i\).

Example:

Input:
3
1 4
2 6
3 5
2
3
7

Output: 3 0

</p>

In the above example, the point 3 belongs to all three intervals, while 7 belongs to none.

inputFormat

The input is given via standard input (stdin) and has the following format:

 n
 a1 b1
 a2 b2
 ...
 an bn
 q
 x1
 x2
 ...
 xq

Here, n is the number of intervals. Each of the following n lines contains two integers \(a_i\) and \(b_i\) representing an interval. Then an integer q is given, followed by q lines each containing a query integer \(x\).

outputFormat

Output a single line containing q integers separated by spaces. Each integer represents the number of intervals that contain the corresponding query point \(x\).

## sample
3
1 4
2 6
3 5
2
3
7
3 0