#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long double eps = 1e-8;
long long read() {
  char ch = getchar();
  long long x = 0;
  int op = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') op = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return x * op;
}
void write(long long a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) write(a / 10);
  putchar(a % 10 + '0');
}
int n, m, Q, fi[100005 << 2], se[100005 << 2], tg1[100005 << 2],
    tg2[100005 << 2], ans[100005];
struct node {
  int l, r;
} a[100005];
const bool cmpnode(const node &x, const node &y) { return x.r < y.r; }
struct questions {
  int l, r, id;
} q[100005];
const bool cmpq(const questions &x, const questions &y) { return x.r < y.r; }
void cal(int &a, int &b, int val) {
  if (val > a)
    b = a, a = val;
  else if (val < a && val > b)
    b = val;
}
void up(int o) {
  fi[o] = se[o] = -1000000000;
  cal(fi[o], se[o], fi[(o << 1)]);
  cal(fi[o], se[o], se[(o << 1)]);
  cal(fi[o], se[o], fi[(o << 1 | 1)]);
  cal(fi[o], se[o], se[(o << 1 | 1)]);
}
void mark(int o, int a, int b) {
  if (fi[o] >= a) {
    fi[o] = b;
    tg1[o] = b;
    if (!tg2[o]) tg2[o] = a;
  }
}
void down(int o) {
  if (tg1[o]) {
    mark((o << 1), tg2[o], tg1[o]);
    mark((o << 1 | 1), tg2[o], tg1[o]);
    tg1[o] = tg2[o] = 0;
  }
}
void build(int o, int l, int r) {
  if (l == r) {
    fi[o] = l, se[o] = -1000000000;
    return;
  }
  int mid = l + r >> 1;
  build((o << 1), l, mid);
  build((o << 1 | 1), mid + 1, r);
  up(o);
}
void modify(int o, int l, int r, int x, int y, int p, int q) {
  if (fi[o] < p) return;
  if (x <= l && r <= y && se[o] < p) {
    mark(o, p, q);
    return;
  }
  down(o);
  int mid = l + r >> 1;
  if (x <= mid) modify((o << 1), l, mid, x, y, p, q);
  if (y > mid) modify((o << 1 | 1), mid + 1, r, x, y, p, q);
  up(o);
}
int query(int o, int l, int r, int x) {
  if (l == r) return fi[o];
  down(o);
  int mid = l + r >> 1;
  if (x <= mid)
    return query((o << 1), l, mid, x);
  else
    return query((o << 1 | 1), mid + 1, r, x);
}
int main() {
  n = read(), m = read();
  for (int i = (1); i <= (m); i++) a[i].l = read(), a[i].r = read();
  sort(a + 1, a + 1 + m, cmpnode);
  Q = read();
  for (int i = (1); i <= (Q); i++)
    q[i].l = read(), q[i].r = read(), q[i].id = i;
  sort(q + 1, q + 1 + Q, cmpq);
  build(1, 1, n);
  int po = 1;
  for (int i = (1); i <= (Q); i++) {
    while (po <= m && a[po].r <= q[i].r) {
      modify(1, 1, n, 1, a[po].l, a[po].l, a[po].r);
      po++;
    }
    ans[q[i].id] = query(1, 1, n, q[i].l);
  }
  for (int i = (1); i <= (Q); i++) write(ans[i]), puts("");
  return 0;
}
