#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
vector<pair<int, int> > qes[N];
int n, m, q, f[N << 2], g[N << 2], link[N], ans[N];
void upd(int rt, int x, int y) {
  if (!f[rt])
    f[rt] = x, g[rt] = y;
  else if (x <= g[rt])
    f[rt] = min(x, f[rt]), g[rt] = y;
}
void down(int rt) {
  if (!f[rt]) return;
  upd(rt << 1, f[rt], g[rt]);
  upd(rt << 1 | 1, f[rt], g[rt]);
  f[rt] = 0;
}
void update(int rt, int l, int r, int L, int R, int x, int y) {
  if (l >= L && r <= R) {
    upd(rt, x, y);
    return;
  }
  down(rt);
  if (L <= ((l + r) >> 1)) update(rt << 1, l, ((l + r) >> 1), L, R, x, y);
  if (R > ((l + r) >> 1))
    update(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R, x, y);
}
int query(int rt, int l, int r, int p) {
  if (l == r) {
    if (f[rt] && f[rt] <= l)
      return g[rt];
    else
      return l;
  }
  down(rt);
  if (p <= ((l + r) >> 1))
    return query(rt << 1, l, ((l + r) >> 1), p);
  else
    return query(rt << 1 | 1, ((l + r) >> 1) + 1, r, p);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    link[r] = l;
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    qes[r].push_back(make_pair(l, i));
  }
  for (int i = 1; i <= n; i++) {
    if (link[i]) update(1, 1, n, 1, link[i], link[i], i);
    for (int j = 0; j <= ((int)(qes[i]).size()) - 1; j++)
      ans[qes[i][j].second] = query(1, 1, n, qes[i][j].first);
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
}
