#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define yes cout << "yes" << endl;
#define YES cout << "YES" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
void never_give_up() {
int n, q;
cin >> n >> q;
vector<pair<int,int>>vt(n + 1);
for(int i = 1; i <= n ;i++){
cin >> vt[i].f;
cin >> vt[i].s;
vt[i].s *= -1;
}
sort(vt.begin(), vt.end());
for(int i = 1; i <= n; i++){
vt[i].s *= -1;
}
while(q--){
int a, b;
cin >> a >> b;
vector<pair<int,int>>v(1);
for(int i = 1; i <= n; i++){
if(vt[i].f >= a && b >= vt[i].s){
v.pb(vt[i]);
}
}
int nn = v.size() - 1;
if(v.size() == 1){
cout << 0 << endl;
}
else{
multiset<int>st;
st.insert(v[1].s);
for(int i = 2;i <= nn; i++){
auto it = st.lower_bound(v[i].s);
if(it != st.begin()){
it--;
st.erase(it);
}
st.insert(v[i].s);
}
cout << st.size() << endl;
}
}
}
void You_can_do_it() {
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int THE_wasd = 1;
//cin >> THE_wasd;
while(THE_wasd--){
never_give_up();
//You_can_do_it();
}
}
//dijkstra on bfs