## # 程序设计：蒜头君的数轴

x1,x2,..., xn (−109≤xi≤109)，表示这些点的坐标，点坐标乱序排列。

4
1 3 7 15

1

## # Monitor

Xiaoteng has a large area of land for growing crops, and the land can be seen as a rectangle of $n \times m$.

But recently Xiaoteng found that his crops were often stolen by a group of people, so he decided to install some monitors to find all the people and then negotiate with them.

However, Xiao Teng bought bad monitors, each monitor can only monitor the crops inside a rectangle. There are $p$ monitors installed by Xiaoteng, and the rectangle monitored by each monitor is known.

Xiao Teng guess that the thieves would also steal $q$ times of crops. he also guessed the range they were going to steal, which was also a rectangle. Xiao Teng wants to know if his monitors can see all the thieves at a time.

Input

There are mutiple test cases.

Each case starts with a line containing two integers $n,m (1 <= n,1 <= m , n \times m <= 10^7)$ which represent the area of the land.

And the secend line contain a integer $p(1 <=p <= 10^6)$ which represent the number of the monitor Xiaoteng has installed. This is followed by p lines each describing a rectangle. Each of these lines contains four intergers $x_1,y_1,x_2~and~y_2(1<=x_1 <=x_2 <= n,1<= y_1 <= y_2 <= m)$ ,meaning the lower left corner and upper right corner of the rectangle.

Next line contain a integer $q(1 <= q<= 10^6)$ which represent the number of times that thieves will steal the crops. This is followed by q lines each describing a rectangle. Each of these lines contains four intergers $x_1,y_1,x_2~and~y_2(1<= x_1 <= x_2 <= n,1<= y_1 <= y_2 <= m)$,meaning the lower left corner and upper right corner of the rectangle.

Output

For each case you should print $q$ lines.

Each line containing YES or NO mean the all thieves whether can be seen.

Sample Input

6 6
3
2 2 4 4
3 3 5 6
5 1 6 2
2
3 2 5 4
1 5 6 5


Sample Output

YES
NO


### # 做法二

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n,m,p,q;
int main(){
while(~scanf("%d%d",&n,&m)){
vector<vector<int> > ve(n+10,vector<int>(m+10,0));
scanf("%d",&p);
int x1,y1,x2,y2;
while(p--){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
// cout<<x1<<y1<<x2<<y2<<endl;
ve[x1][y1]++;
ve[x2+1][y1]--;
ve[x1][y2+1]--;
ve[x2+1][y2+1]++;
}
//二维差分求前缀和
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
ve[i][j]+=ve[i-1][j]+ve[i][j-1]-ve[i-1][j-1];
}
//把每个格子都置为1
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
ve[i][j]=min(1,ve[i][j]);
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
ve[i][j]+=ve[i-1][j]+ve[i][j-1]-ve[i-1][j-1];
}
scanf("%d",&q);
while(q--){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int t=ve[x2][y2]-ve[x2][y1-1]-ve[x1-1][y2]+ve[x1-1][y1-1];
if(t==(x2-x1+1)*(y2-y1+1)) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return 0;
}