#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <set> #include <vector> #include <map> #include <queue> #include <set> #include <algorithm> #include <limits> using namespace std; typedef long long LL; const int MAXN=100000+100; const int INF = numeric_limits<int>::max(); const LL LL_INF= numeric_limits<LL>::max(); struct Tree { int cnt; }tr[2][MAXN<<2]; #define lson L,mid,rt<<1 #define rson mid+1,R,rt<<1|1 void build(int L,int R,int rt){ tr[0][rt].cnt=tr[1][rt].cnt=0; if(L==R){ return ; } int mid=(L+R)>>1; build(lson);build(rson); } void update(int L,int R,int rt,int pos,int pos1){ if(L==R){ tr[pos1][rt].cnt=1;return ; } int mid=(L+R)>>1; if(pos<=mid)update(lson,pos,pos1); else update(rson,pos,pos1); tr[pos1][rt].cnt=tr[pos1][rt<<1].cnt+tr[pos1][rt<<1|1].cnt; } int query(int L,int R,int rt,int l,int r,int pos1){ if(l<=L&&R<=r)return tr[pos1][rt].cnt; int mid=(L+R)>>1,ans=0; if(l<=mid)ans+=query(lson,l,r,pos1); if(r>mid)ans+=query(rson,l,r,pos1); return ans; } int main() { int T; scanf("%d",&T); while(T--){ int n,m,K,Q; scanf("%d%d%d%d",&n,&m,&K,&Q); int tn=max(n,m); build(1,tn,1); for(int i=0,x,y;i<K;i++){ scanf("%d%d",&x,&y); update(1,tn,1,x,0); update(1,tn,1,y,1); } for(int i=0,x1,y1,x2,y2;i<Q;i++){ scanf("%d%d%d%d",&x1,&y1,&x2,&y2); int tmp0=query(1,tn,1,x1,x2,0); int tmp1=query(1,tn,1,y1,y2,1); if(tmp0==x2-x1+1||tmp1==y2-y1+1)puts("Yes"); else puts("No"); } } return 0; }
|