#include <bits/stdc++.h>
using namespace std;
struct data {
  int l, r, id;
  bool operator<(const data &a) const { return r < a.r; }
} a[100010], b[100010];
int mx[100010 << 2], sx[100010 << 2], ta[100010 << 2], tb[100010 << 2],
    ans[100010];
inline void pushup(int x) {
  int l = x << 1, r = x << 1 | 1;
  if (mx[l] > mx[r])
    mx[x] = mx[l], sx[x] = max(sx[l], mx[r]);
  else if (mx[l] < mx[r])
    mx[x] = mx[r], sx[x] = max(mx[l], sx[r]);
  else
    mx[x] = mx[l], sx[x] = max(sx[l], sx[r]);
}
inline void pushdown(int x) {
  int l = x << 1, r = x << 1 | 1;
  if (mx[l] >= ta[x])
    mx[l] = tb[x], ta[l] = min(ta[l], ta[x]), tb[l] = max(tb[l], tb[x]);
  if (mx[r] >= ta[x])
    mx[r] = tb[x], ta[r] = min(ta[r], ta[x]), tb[r] = max(tb[r], tb[x]);
  ta[x] = 1 << 30, tb[x] = 0;
}
void build(int l, int r, int x) {
  ta[x] = 1 << 30, tb[x] = 0;
  if (l == r) {
    mx[x] = l, sx[x] = -1 << 30;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, x << 1), build(mid + 1, r, x << 1 | 1);
  pushup(x);
}
void update(int b, int e, int va, int vb, int l, int r, int x) {
  if (mx[x] < va) return;
  if (b <= l && r <= e && mx[x] >= va && sx[x] < va) {
    mx[x] = vb, ta[x] = min(ta[x], va), tb[x] = max(tb[x], vb);
    return;
  }
  pushdown(x);
  int mid = (l + r) >> 1;
  if (b <= mid) update(b, e, va, vb, l, mid, x << 1);
  if (e > mid) update(b, e, va, vb, mid + 1, r, x << 1 | 1);
  pushup(x);
}
int query(int p, int l, int r, int x) {
  if (l == r) return mx[x];
  pushdown(x);
  int mid = (l + r) >> 1;
  if (p <= mid)
    return query(p, l, mid, x << 1);
  else
    return query(p, mid + 1, r, x << 1 | 1);
}
int main() {
  int n, m, q, i, p = 1;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) scanf("%d%d", &a[i].l, &a[i].r);
  scanf("%d", &q);
  for (i = 1; i <= q; i++) scanf("%d%d", &b[i].l, &b[i].r), b[i].id = i;
  sort(a + 1, a + m + 1), sort(b + 1, b + q + 1);
  build(0, n, 1);
  for (i = 1; i <= q; i++) {
    while (p <= m && a[p].r <= b[i].r)
      update(0, a[p].l, a[p].l, a[p].r, 0, n, 1), p++;
    ans[b[i].id] = query(b[i].l, 0, n, 1);
  }
  for (i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
