#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
class node {
 public:
  int x;
  node() { x = 1e9; }
};
node operator+(node x, node y) {
  node res;
  res.x = max(x.x, y.x);
  return res;
}
node tree[N << 2];
int lazy[N << 2];
void doit(int x, int v) {
  if (!v) return;
  if (!lazy[x])
    lazy[x] = v;
  else
    lazy[x] = min(lazy[x], v);
  tree[x].x = min(tree[x].x, v);
}
void push(int x) {
  doit(x + x, lazy[x]);
  doit(x + x + 1, lazy[x]);
  lazy[x] = 0;
}
void update(int x, int l, int r, int x1, int x2, int d) {
  if (x2 < l or r < x1) return;
  if (x1 <= l and r <= x2) {
    doit(x, d);
    return;
  }
  push(x);
  int m = (l + r) >> 1;
  update(x + x, l, m, x1, x2, d);
  update(x + x + 1, m + 1, r, x1, x2, d);
  tree[x] = tree[x + x] + tree[x + x + 1];
}
int query(int x, int l, int r, int x1, int x2, int k) {
  if (r < x1 or x2 < l or tree[x].x <= k) return -1;
  if (l == r) {
    return tree[x].x > k ? l : -1;
  }
  int m = (l + r) >> 1;
  push(x);
  int res = query(x + x, l, m, x1, x2, k);
  if (res == -1) res = query(x + x + 1, m + 1, r, x1, x2, k);
  return res;
}
int n, m, q;
vector<int> rope[N];
vector<pair<int, int> > qu[N];
int ans[N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    rope[l].push_back(r);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    qu[l].push_back({r, i});
  }
  for (int l = n; l >= 1; l--) {
    for (auto r : rope[l]) update(1, 1, n, l, r - 1, r);
    for (auto tmp : qu[l]) {
      int r, id;
      tie(r, id) = tmp;
      int res = query(1, 1, n, l, r - 1, r);
      if (res == -1) res = r;
      ans[id] = res;
    }
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
