#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); }
bool cmp(array<int,2> a,array<int,2> b){
if(a[0]!=b[0]) return a<b;
else return a[1]>b[1];
}
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(),cmp);
for(int i=0; i<m; i++){
int a,b;
cin >> a >> b;
deque<array<int,2>> V;
multiset<int> kk;
for(int j=0; j<n; j++){
if(k[j][0]>=a && k[j][1]<=b){
V.push_back(k[j]);
}
}
for(int j=0; j<V.size(); j++){
if(j==0){
kk.insert(V[j][1]);
continue;
}
auto it=kk.lower_bound(V[j][1]);
if(it==kk.begin()) kk.insert(V[j][1]);
else{
it--;
kk.erase(it);
kk.insert(V[j][1]);
}
}
cout << kk.size() << 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();
}
}