Problem H. Historical search

Author:A. Baranov   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

Young historian Vasya, as part of his dissertation work, is engaged in comparing records from documents stored in the archive.

Each document covers a specific time interval and contains information about events that occurred during that time.

Vasya is interested in how the same event was covered in different sources.

To achieve this, he has to search for documents each time that could contain a record of the event he is interested in.

As there could be too many such events, you are required to write a program that, for a given event, would perform a search for all relevant documents.

Input format

At the beginning of the input data there is a natural number N, followed by 2 × N integers specifying the time interval [Ai, Bi] for each document.

Then, there is a number M and exactly M queries containing the time of the event Cj.

Output format

The output data should contain a set of answers to each of these queries.
It starts with the number of detected documents, followed by their numbers.

It is assumed that the numbering of documents starts from zero.

Constraints

Constraints: The total number of documents in the output does not exceed 106.

 − 106 ≤ Ai ≤ Bi ≤ 106,  − 106 ≤ Cj ≤ 106, 1 ≤ N ≤ 2 ⋅ 104, 1 ≤ M ≤ 105

Sample tests

No. Standard input Standard output
1
6
-1  0
-1 -1
-1  0
 4  4
 2  3
 3  3

8
-1
 0
 2
 3
 1
-2
 4
 5
3 0 1 2
2 0 2
1 4
2 4 5
0
0
1 3
0

0.063s 0.008s 13