D. Bricks
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

There are $$$N$$$ bricks numbered from $$$1$$$ to $$$N$$$ and $$$M$$$ colors numbered from $$$1$$$ to $$$M$$$. Each brick $$$i$$$ has a size $$$A_i$$$ and color $$$B_i$$$. It is guaranteed that there is at least one brick of each color.

A tower made of some set of bricks is called $$$k$$$-beautiful if the absolute difference in sizes between every two adjacent bricks is at most $$$k$$$.

Your task is to answer $$$Q$$$ queries. The $$$j$$$-th query is: can at least one $$$K_j$$$-beautiful tower be made using all the bricks of the colors $$$X_j$$$ and $$$Y_j$$$ and no bricks of any other colors? It is guaranteed that $$$X_j$$$ and $$$Y_j$$$ are distinct.

Input

The first line contains two integers, $$$N$$$ and $$$M$$$.

The next $$$N$$$ lines describe the bricks. The $$$i$$$-th of these lines contains two integers $$$A_i$$$ and $$$B_i$$$.

The next line contains a single integer, $$$Q$$$.

The next $$$Q$$$ lines describe the queries. The $$$j$$$-th of these lines contain three integers, $$$K_j$$$, $$$X_j$$$ and $$$Y_j$$$.

Constraints

  • $$$1 \leq M \leq N \leq 2 \cdot 10^5$$$.
  • $$$1 \leq Q \leq 2 \cdot 10^5$$$.
  • For all $$$1 \leq i \leq N$$$:
    • $$$1 \leq A_i \leq 2 \cdot 10^9$$$.
    • $$$1 \leq B_i \leq M$$$.
  • There is at least one brick of each color.
  • For all $$$1 \leq j \leq Q$$$:
    • $$$1 \leq K_j \leq 2 \cdot 10^9$$$.
    • $$$1 \leq X_j \leq M$$$.
    • $$$1 \leq Y_j \leq M$$$.
    • $$$X_j \neq Y_j$$$.
Output

For each query, you should print either YES or NO on a separate line.

Examples
Input
8 4
5 1
10 2
2 2
20 3
33 4
6 1
17 2
42 1
5
13 3 4
7 2 3
25 1 3
20 1 2
20 2 4
Output
YES
NO
YES
NO
YES
Input
5 2
5 1
5 1
10 2
15 1
20 2
1
5 1 2
Output
YES
Input
10 4
35 4
92 3
97 3
19 1
20 1
84 4
11 1
26 2
60 3
29 3
10
8 2 4
10 2 4
34 2 3
43 2 3
47 1 2
24 2 3
30 3 4
45 1 3
46 1 4
14 2 3
Output
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO