#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int int_fast64_t
#define ul uint_fast32_t
#define ll int_fast64_t
#define dll long double
#define ull uint_fast64_t
#define spektar this_thread::sleep_for(chrono::milliseconds(50))
ll log2floor(ull n){ return 63-__builtin_clzll(n); }
void solve(){
int n,m;
cin >> n >> m;
vector<array<int,2>> k(n);
for(auto& [a,b]:k) cin >> a >> b;
sort(k.begin(),k.end());
map<array<int,2>,int> idx;
map<int,int> prev;
for(int i=0; i<n; i++){
idx[k[i]]=i;
prev[i]=-1;
}
map<int,int> kk;
vector<bool> used(n);
for(int i=0; i<n; i++){
kk[i]=-1;
for(int j=0; j<n; j++){
if(used[j]) continue;
if(k[j][0]>k[i][0] && k[j][1]>k[i][1]){
used[j]=true;
kk[i]=j;
prev[j]=i;
break;
}
}
}
for(int i=0; i<m; i++){
int a,b;
cin >> a >> b;
multiset<array<int,2>> V;
map<int,int> kk1=kk;
for(int j=0; j<n; j++){
if(k[j][0]>=a && k[j][1]<=b) V.insert(k[j]);
else if(prev[j]!=-1) kk1[prev[j]]=-1;
}
int s=0;
while(V.size()){
auto it=V.begin();
if(kk1[idx[*it]]==-1){
V.erase(it);
s++;
continue;
}
V.erase(it);
}
cout << s << endl;
}
}
signed main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
//cin >> t;
while(t--){
solve();
}
}