#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long mod = 1000000007;
const int N = 1e5 + 5, blksz = 400;
int jumpx[N];
int jumpblk[blksz][blksz];
void update(int x, int y) {
  int blknm = x / blksz;
  jumpx[x] = max(jumpx[x], y);
  for (int i = blksz - 1; i >= 0; i--) {
    if (jumpblk[blknm][i] >= x) {
      jumpblk[blknm][i] = max(jumpblk[blknm][i], y);
    }
  }
}
void consturct(int n) {
  for (int i = 1; i <= n; i++) {
    jumpx[i] = i;
    jumpblk[i / blksz][i % blksz] = i;
  }
}
int query(int x, int y) {
  int s = x;
  int e = x;
  while (s % blksz && s <= e) {
    e = max(e, jumpx[s]);
    s++;
  }
  if (s > e) return e;
  while (s <= e) {
    int at = e - s;
    if (at >= blksz) at = blksz - 1;
    e = max(e, jumpblk[s / blksz][at]);
    s += blksz;
  }
  return e;
}
int res[N];
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > g(m);
  for (int i = 0; i < m; i++) {
    cin >> g[i].second >> g[i].first;
  }
  sort(g.begin(), g.end());
  int q;
  cin >> q;
  vector<pair<int, pair<int, int> > > qur(q);
  for (int i = 0; i < q; i++) {
    cin >> qur[i].second.first >> qur[i].first, qur[i].second.second = i;
  }
  consturct(n);
  sort(qur.begin(), qur.end());
  for (int i = 0, indx = 0; i < (int)qur.size(); i++) {
    while (indx < (int)g.size() && g[indx].first <= qur[i].first)
      update(g[indx].second, g[indx].first), indx++;
    res[qur[i].second.second] = query(qur[i].second.first, qur[i].first);
  }
  for (int i = 0; i < q; i++) cout << res[i] << '\n';
  return 0;
}
