#include<bits/stdc++.h>
using namespace std;
signed main() {
ios :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define endl "\n"
int n,q;
cin >> n >> q;
vector <int> s(n+1,-1),e(n+1,-1);
for (int i = 1; i <= n; i++) {
cin >> s[i] >> e[i];
}
vector <pair<int,int>> t(4*n+5,{INT_MAX,INT_MAX});
function<void(int,int,int,int,pair<int,int>)> update = [&](int node, int l, int r, int pos, pair<int,int> val) {
// cout << 1 << endl;
if (pos < l || pos > r) return;
if (l == r) {
t[node] = min(t[node],val);
return;
}
int mid = (l+r)/2;
update(node*2, l,mid,pos,val);
update(node*2+1,mid+1,r,pos,val);
t[node] = min(t[node*2],t[node*2+1]);
};
function <pair<int,int>(int,int,int,int,int)> getmax = [&](int node, int l, int r, int L, int R) {
if (l > R || r < L) return make_pair(INT_MAX,INT_MAX);
if (L <= l && r <= R) return t[node];
int mid = (l+r)/2;
return min(getmax(node*2,l,mid,L,R),getmax(node*2+1,mid+1,r,L,R));
};
vector <pair<int,int>> r;
for (int i = 1; i <= n; i++) {
r.emplace_back(e[i],i);
}
sort(r.begin(),r.end());
for (int i = 0; i < n; i++) {
// cout << r[i].first << endl;
update(1,0,n,i,make_pair(s[r[i].second],r[i].second));
}
vector <vector<int>> up(n+1,vector<int>(20,-1));
for (int i = 1; i <= n; i++) {
int l = lower_bound(r.begin(),r.end(),make_pair(s[i],0)) - r.begin();
int tr = upper_bound(r.begin(),r.end(),make_pair(e[i],n)) - r.begin() - 1;
if (tr < l) continue;
up[i][0] = getmax(1,0,n,l,tr).second;
// cout << i << "---->" << s[i] << " " << e[i] << endl;
// cout << i << " ---> " << l << " " << tr << " " << up[i][0] << endl;
}
for (int i = 1; i <= 19; i++) {
for (int j = 1; j <= n; j++) {
up[j][i] = up[up[j][i-1]][i-1];
}
}
while (q--) {
int S,E;
cin >> S >> E;
if (s[S] > e[E]) {
// cout << 1 << endl;
cout << "impossible" << endl;
continue;
}
if (S == E) {
cout << 0 << endl;
continue;
}
int cur = 0;
if (s[E] <= e[S] && e[S] <= e[E]) {
cout << cur+1 << endl;
continue;
}
for (int i = 19; i >= 0; i--) {
if (e[S] < s[up[E][i]]) {
cur += (1<<i);
E = up[E][i];
}
}
// cout << cur << endl;
// cout << E << endl;
if (s[E] <= e[S] && e[S] <= e[E]) {
cout << cur+1 << endl;
continue;
}
cur++;
E = up[E][0];
// cout << E << endl;
if (s[E] <= e[S] && e[S] <= e[E]) {
cout << cur+1 << endl;
continue;
}
cout << "impossible" << endl;
}
}