Passport

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Passport is a certificate which is used worldwide when a traveler enters foreign countries.

In a planet, there are NN countries, numbered from 11 to NN. Each country issues a passport. When a traveler has a passport issued by the country ii (1iN1 ≤ i ≤ N), the traveler can enter the countries L_i,L_i+1,,R_iL\_i , L\_{i + 1}, \dots , R\_i. Here, it is guaranteed that the traveler can enter the country where the passport was issued. Namely, L_iiR_iL\_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 NN countries by repeating the following two actions.

  • He gets a passport issued by the country where he is currently staying.
  • He moves to a country where he can enter using a passport he currently has.

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 QQ possible countries X_1,X_2,,X_QX\_1, X\_2, \dots , 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 NN countries, and, if it is possible, calculates the minimum number of passports he needs to get.

입력

Read the following data from the standard input.

NN

L_1L\_1 R_1R\_1

L_2L\_2 R_2R\_2

\vdots

L_NL\_N R_NR\_N

QQ

X_1X\_1

X_2X\_2

\vdots

X_QX\_Q

출력

Write QQ lines to the standard output. The jj-th line (1jQ1 ≤ j ≤ Q) corresponds to the case where your friend lives in the country X_jX\_j. If it is possible for him to visit all of the NN countries, this line should contain the minimum number of passports he needs to get. Otherwise, this line should contain -1.

제한

  • 2N200,0002 ≤ N ≤ 200\\,000.
  • 1L_iiR_iN1 ≤ L\_i ≤ i ≤ R\_i ≤ N (1iN1 ≤ i ≤ N).
  • 1QN1 ≤ Q ≤ N.
  • 1X_jN1 ≤ X\_j ≤ N (1jQ1 ≤ j ≤ Q).
  • X_j<X_j+1X\_j < X\_{j+1} (1jQ11 ≤ j ≤ Q - 1).
  • Given values are all integers.