#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define inf (int)3e18
#define ff first
#define ss second
#define deb(x) cerr << #x << " = " << x << '\n'
using vi = vector<int>;
using pii = pair<int, int>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAX = 5e5 + 5, MOD = 1e9 + 7;
bool cmp(pii a, pii b)
{
if (a.ff != b.ff)
return a.ff < b.ff;
return a.ss > b.ss;
}
void solve()
{
int n, q;
cin >> n >> q;
vector<pii> arr;
for (int i = 0; i < n; i++)
{
int l, r;
cin >> l >> r;
arr.push_back(make_pair(l, r));
}
for (int i = 0; i < q; i++)
{
int a, b;
cin >> a >> b;
vi ans;
vector<pii> vt;
for (int i = 0; i < n; i++)
if (arr[i].ff >= a && arr[i].ss <= b)
vt.push_back(arr[i]);
sort(all(vt), cmp);
for (auto [l, r] : vt)
{
auto it = upper_bound(all(ans), r, greater<int>());
if (it == ans.end())
ans.push_back(r);
else
*it = r;
}
cout << ans.size() << '\n';
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1;
// cin >> tt;
while (tt--)
solve();
}