#include <bits/stdc++.h>
using std::max;
using std::min;
using std::sort;
using std::swap;
using std::vector;
const int maxn = 100017;
int val[maxn << 2], tag[maxn << 2];
int N, M, Q;
int rp[maxn];
struct Query {
  int id, x;
};
vector<Query> q[maxn];
int ans[maxn];
struct node {
  int mx, sc, tag;
} tree[maxn << 2];
void pushdown(int i) {
  if (tree[i].tag == 0) return;
  if (tree[(i << 1)].mx > tree[i].sc)
    tree[(i << 1)].mx = tree[(i << 1)].tag = tree[i].tag;
  if (tree[(i << 1 | 1)].mx > tree[i].sc)
    tree[(i << 1 | 1)].mx = tree[(i << 1 | 1)].tag = tree[i].tag;
  tree[i].tag = 0;
  return;
}
void pushup(int i) {
  tree[i].mx = max(tree[(i << 1)].mx, tree[(i << 1 | 1)].mx);
  tree[i].sc = max(tree[(i << 1)].sc, tree[(i << 1 | 1)].sc);
  if (tree[(i << 1)].mx != tree[(i << 1 | 1)].mx)
    tree[i].sc = max(tree[i].sc, min(tree[(i << 1)].mx, tree[(i << 1 | 1)].mx));
  return;
}
void update(int L, int R, int l, int r, int li, int ri, int i) {
  if (li > tree[i].mx) return;
  if (l <= L && R <= r) {
    if (li > tree[i].sc)
      tree[i].mx = tree[i].tag = ri;
    else {
      int mid = L + R >> 1;
      pushdown(i);
      update(L, mid, l, r, li, ri, (i << 1));
      update(mid + 1, R, l, r, li, ri, (i << 1 | 1));
      pushup(i);
    }
  } else {
    int mid = L + R >> 1;
    pushdown(i);
    if (l <= mid) update(L, mid, l, r, li, ri, (i << 1));
    if (r > mid) update(mid + 1, R, l, r, li, ri, (i << 1 | 1));
    pushup(i);
  }
  return;
}
void update(int L, int R, int x, int i) {
  if (L == R) {
    tree[i].mx = x;
    return;
  }
  pushdown(i);
  int mid = L + R >> 1;
  if (x <= mid)
    update(L, mid, x, (i << 1));
  else
    update(mid + 1, R, x, (i << 1 | 1));
  return pushup(i);
}
int query(int L, int R, int x, int i) {
  if (L == R) return tree[i].mx;
  pushdown(i);
  int mid = L + R >> 1;
  if (x <= mid)
    return query(L, mid, x, (i << 1));
  else
    return query(mid + 1, R, x, (i << 1 | 1));
}
int main() {
  scanf("%d%d", &N, &M);
  int x, y;
  for (int i = 1; i <= M; i++) scanf("%d%d", &x, &y), rp[y] = x;
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++)
    scanf("%d%d", &x, &y), q[y].push_back((Query){i, x});
  for (int i = 1; i <= N; i++) {
    update(1, N, i, 1);
    if (rp[i]) update(1, N, 1, rp[i], rp[i], i, 1);
    for (int k = 0; k < q[i].size(); k++)
      ans[q[i][k].id] = query(1, N, q[i][k].x, 1);
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
