#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<long long, long long>
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define test cout << "yep ";
const int MAX = 1e3 + 5;
const int INF = 8e17;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool comp(pair<int, int>a, pair<int, int>b){
if(a.first == b.first){
return a.second >= b.second;
}
return a.first < b.first;
}
signed main(){
IOS;
//my code goes here:
int n, q;
cin >> n >> q;
vector<pii>vt;
for(int i = 1; i <= n; i++){
int x, y;
cin >> x >> y;
vt.push_back({x, y});
}
while(q--){
int a, b;
cin >> a >> b;
vector<pii>v;
for(auto [l, r] : vt){
if(l >= a && r <= b){
v.push_back({l, r});
}
}
if(v.size() == 0){
cout << 0 << endl;
continue;
}
if(v.size() == 1){
cout << 1 << endl;
continue;
}
sort(v.begin(), v.end(), comp);
multiset<int>st;
for(auto [l, r] : v){
if(st.size() == 0){
st.insert(r);
continue;
}
auto it = lower_bound(st.begin(), st.end(), r);
if(it == st.begin()){
st.insert(r);
}
else{
it--;
st.erase(it);
st.insert(r);
}
}
cout << st.size() << endl;
}
}