/*author : umbraphile*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define kaneki ios::sync_with_stdio(0);cin.tie(nullptr)
#define TEST int t; cin >> t; while (t --)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(),a.rend()
#define mat vector<vector<int>>
const int MOD = 1e9 + 7;
const int inf = 2e18;
const int aura = LLONG_MIN;
const int MAXN = 1e5 + 5;
const int LOG = 20;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
// i dan j ga otish mumkun :
// if S_j <= E_i and E_i <= E_j
// x y kiritladi sen shortest path topasan xdan y ga yetib borish uchun
// maybe just dijkstra no weihgt yogu bfs?
int S[MAXN];
int E[MAXN];
// int dist[MAXN];
int par[MAXN];
// void solve()
// {
// int n,q; cin >> n >> q;
// for(int i = 1; i <= n; ++ i) cin >> S[i] >> E[i];
// while(q --)
// {
// int x, y; cin >> x >> y;
// if(x==y){cout << 0 << "\n";continue;}
// for(int i = 1; i <= n; ++ i) dist[i] = -1;
// queue<int> q;
// q.push(x);
// dist[x] = 0;
// bool ok = false;
// while(!q.empty())
// {
// int d = q.front();
// q.pop();
// if(d == y){cout << dist[d] << "\n";ok = true;break;}
// for(int i = 1; i <= n; ++ i){
// if(dist[i] == -1){
// if(S[i] <= E[d] && E[d] <= E[i])
// {
// dist[i] = dist[d] + 1;
// q.push(i);
// }
// }
// }
// }
// if(!ok) cout << "impossible\n";
// }
// }
// task1
void solve()
{
int n,q; cin >> n >> q;
for(int i = 1; i <= n; ++ i){
cin >> S[i] >> E[i];
par[i] = -1;
}
for(int i = 1; i <= n; ++ i)
{
for(int j = 1; j <= n; ++ j)
{
if(S[j] <= E[i] && E[i] <= E[j]){par[i] = j;break;}
}
}
while(q --)
{
int x, y; cin >> x >> y;
if(x==y){cout << 0 << "\n";continue;}
int d = x;
int cnt = 0;
bool ok = false;
for(int i = 0; i < n; ++ i)
{
d = par[d];
if(d == -1) break;
cnt ++;
if(d == y){ok = true;break;}
}
if(ok) cout << cnt << "\n";
else cout << "impossible\n";
}
}
signed main()
{
//#ifndef LOCAL
//freopen("input.txt", "mx", stdin);
//freopen("output.txt", "x", stdout);
//#endif
kaneki;
// pre();
// sieve();
solve();
}