#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
const int N=4e6+5;
struct node{
int x,y,id;
}a[N];
int lsh[N],len,n,m,len1,tot[N];
int ans[N][5];
struct Binarytree{
int t[N<<1];
void ud(int x){
while(x<=n){
t[x]++;
x+=x&-x;
}
}
int ask(int x){
int ret=0;
while(x){
ret+=t[x];
x-=x&-x;
}
return ret;
}
}bit;
int lsh_(int x){
return lower_bound(lsh+1,lsh+len+1,x)-lsh;
}
int32_t main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
rep(i,1,n){
int x,y;
cin>>x>>y;
a[i]={x,y,0};
lsh[++len1]=y;
}
rep(i,1,m){
int x1_,y1_,x2_,y2_;
cin>>x1_>>y1_>>x2_>>y2_;
a[++n]={x1_-1,y1_-1,i};
a[++n]={x2_,y2_,i};
a[++n]={x1_-1,y2_,i};
a[++n]={x2_,y1_-1,i};
lsh[++len1]=y1_-1;lsh[++len1]=y2_;
}
sort(lsh+1,lsh+len1+1);
len=unique(lsh+1,lsh+len1+1)-lsh-1;
stable_sort(a+1,a+n+1,[](const node& x_,const node& y_){
return x_.x<y_.x;
});
rep(i,1,n){
if(a[i].id){
ans[a[i].id][++tot[a[i].id]]=bit.ask(lsh_(a[i].y));
}else{
bit.ud(lsh_(a[i].y));
}
}
rep(i,1,m){
sort(ans[i]+1,ans[i]+5);
cout<<ans[i][4]-ans[i][3]-ans[i][2]+ans[i][1]<<'\n';
}
}