AT_abc389_f [ABC389F] Rated Range

Description

Takahashi plans to participate in $ N $ AtCoder contests. In the $ i $ -th contest ( $ 1 \leq i \leq N $ ), if his rating is between $ L_i $ and $ R_i $ (inclusive), his rating increases by $ 1 $ . You are given $ Q $ queries in the following format: - An integer $ X $ is given. Assuming that Takahashi's initial rating is $ X $ , determine his rating after participating in all $ N $ contests.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ L_1 $ $ R_1 $ $ L_2 $ $ R_2 $ $ \vdots $ $ L_N $ $ R_N $ $ Q $ $ \text{query}_1 $ $ \text{query}_2 $ $ \vdots $ $ \text{query}_Q $ Here, $ \text{query}_i $ is the $ i $ -th query in the form: > $ X $

Output Format

Print $ Q $ lines. The $ i $ -th line should contain the answer to the $ i $ -th query.

Explanation/Hint

### Sample Explanation 1 For the 1st query, the rating changes as follows: - In the 1st contest, the rating is between $ 1 $ and $ 5 $ , so it increases by $ 1 $ , becoming $ 4 $ . - In the 2nd contest, the rating is not between $ 1 $ and $ 3 $ , so it remains $ 4 $ . - In the 3rd contest, the rating is between $ 3 $ and $ 6 $ , so it increases by $ 1 $ , becoming $ 5 $ . - In the 4th contest, the rating is not between $ 2 $ and $ 4 $ , so it remains $ 5 $ . - In the 5th contest, the rating is between $ 4 $ and $ 7 $ , so it increases by $ 1 $ , becoming $ 6 $ . For the 2nd query, the rating increases in the 1st, 2nd, 3rd, and 5th contests, ending at $ 6 $ . For the 3rd query, the rating increases in the 1st, 3rd, and 5th contests, ending at $ 8 $ . ### Constraints - $ 1 \leq N \leq 2 \times 10^5 $ - $ 1 \leq L_i \leq R_i \leq 5 \times 10^5 $ $ (1 \leq i \leq N) $ - $ 1 \leq Q \leq 3 \times 10^5 $ - For each query, $ 1 \leq X \leq 5 \times 10^5 $ . - All input values are integers.