#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, pos = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') pos = 0;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return pos ? x : -x;
}
const int N = 1e5 + 200;
pair<int, int> p[N];
int cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
pair<int, int> stk[N];
vector<int> G[N];
int f[112][N], g[N];
int c[N], B, maxr, n, m;
void add(int x, int w) {
  for (; x <= maxr; x += x & (-x)) c[x] = max(c[x], w);
}
int query(int x) {
  int res = 0;
  for (; x; x -= x & (-x)) res = max(res, c[x]);
  return res;
}
int calc(int l, int r, int ql, int qr) {
  for (int j = ql; j <= qr; ++j) {
    if (l <= g[j] && g[j] <= r) r = j;
  }
  return r;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; ++i) {
    p[i].first = read(), p[i].second = read();
    G[p[i].first].push_back(p[i].second);
    g[p[i].second] = p[i].first;
  }
  for (int i = 1; i <= n; ++i) {
    if (G[i].size()) sort(G[i].begin(), G[i].end());
  }
  sort(p + 1, p + m + 1);
  B = sqrt(n * 10);
  for (int i = 0; i <= n / B; ++i) {
    int l = i * B, r = min(n, (i + 1) * B - 1);
    maxr = r;
    if (l > r) continue;
    for (int j = 1; j <= r; ++j) f[i][j] = j, c[j] = 0;
    for (int j = r; j >= 1; --j) {
      for (int k = 0; k < (int)G[j].size(); k++) {
        if ((k + 1 != (int)G[j].size() && (int)G[j][k + 1] > maxr) ||
            k + 1 == (int)G[j].size()) {
          if (G[j][k] <= maxr) f[i][j] = max(G[j][k], query(G[j][k]));
          break;
        }
      }
      if (f[i][j]) {
        add(j, f[i][j]);
      }
    }
  }
  int q = read();
  for (int i = 1; i <= q; ++i) {
    int ql = read(), qr = read();
    int l = ql / B, r = qr / B;
    if (l == r) {
      printf("%d\n", calc(ql, ql, ql, qr));
    } else {
      printf("%d\n", calc(ql, f[r - 1][ql], r * B, qr));
    }
  }
  return 0;
}
