Passport is a certificate which is used worldwide when a traveler enters foreign countries.
In a planet, there are N countries, numbered from 1 to N. Each country issues a passport. When a traveler has a passport issued by the country i (1≤i≤N), the traveler can enter the countries L_i,L_i+1,…,R_i. Here, it is guaranteed that the traveler can enter the country where the passport was issued. Namely, L_i≤i≤R_i is satisfied.
You have a friend who likes traveling. Although he dreams of traveling around the world, he does not have a passport in the beginning. Thus, he plans to visit all of the N countries by repeating the following two actions.
When you hear about his plan, you are wondering whether it is possible to realize the plan, and, if it is possible, what is the minimum number of passports he needs to get. Since you do not know where he lives, you consider Q possible countries X_1,X_2,…,X_Q where he lives.
Write a program which, given information of the passports and the possibilities of his living place, for each possibility, determines whether it is possible for him to visit all of the N countries, and, if it is possible, calculates the minimum number of passports he needs to get.
Read the following data from the standard input.
N
L_1 R_1
L_2 R_2
⋮
L_N R_N
Q
X_1
X_2
⋮
X_Q
Write Q lines to the standard output. The j-th line (1≤j≤Q) corresponds to the case where your friend lives in the country X_j. If it is possible for him to visit all of the N countries, this line should contain the minimum number of passports he needs to get. Otherwise, this line should contain -1.