#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline void read(int &x) {
  char c = nc(), b = 1;
  for (; !(c >= '0' && c <= '9'); c = nc())
    if (c == '-') b = -1;
  for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc())
    ;
  x *= b;
}
const int N = 100005;
int T[N << 2], R[N << 2], F[N << 2], G[N << 2];
inline void mark(int x, int a, int b) {
  if (T[x] >= a) {
    T[x] = b;
    F[x] = b;
    if (!G[x]) G[x] = a;
  }
}
inline void calc(int &x, int &y, int &z) {
  if (z > x)
    y = x, x = z;
  else if (z < x && z > y)
    y = z;
}
inline void upd(int x) {
  T[x] = R[x] = -1 << 30;
  calc(T[x], R[x], T[x << 1]);
  calc(T[x], R[x], R[x << 1]);
  calc(T[x], R[x], T[x << 1 | 1]);
  calc(T[x], R[x], R[x << 1 | 1]);
}
inline void push(int x) {
  if (F[x]) {
    mark(x << 1, G[x], F[x]);
    mark(x << 1 | 1, G[x], F[x]);
    F[x] = 0;
    G[x] = 0;
  }
}
inline void Build(int x, int l, int r) {
  if (l == r) {
    T[x] = l;
    R[x] = -1 << 30;
    return;
  }
  int mid = (l + r) >> 1;
  Build(x << 1, l, mid);
  Build(x << 1 | 1, mid + 1, r);
  upd(x);
}
inline void Modify(int x, int l, int r, int ql, int qr, int a, int b) {
  if (T[x] < a) return;
  if (ql <= l && r <= qr && R[x] < a) {
    mark(x, a, b);
    return;
  }
  push(x);
  int mid = (l + r) >> 1;
  if (ql <= mid) Modify(x << 1, l, mid, ql, qr, a, b);
  if (qr > mid) Modify(x << 1 | 1, mid + 1, r, ql, qr, a, b);
  upd(x);
}
inline int Query(int x, int l, int r, int t) {
  if (l == r) return T[x];
  push(x);
  int mid = (l + r) >> 1;
  if (t <= mid)
    return Query(x << 1, l, mid, t);
  else
    return Query(x << 1 | 1, mid + 1, r, t);
}
int n, m, pos[N];
int ans[N];
struct abcd {
  int l, r, idx;
  bool operator<(const abcd &B) const { return r < B.r; }
} que[N];
int main() {
  int l, r;
  read(n);
  read(m);
  for (int i = 1; i <= m; i++) read(l), read(r), pos[r] = l;
  int Q;
  read(Q);
  for (int i = 1; i <= Q; i++) {
    read(que[i].l);
    read(que[i].r);
    que[i].idx = i;
  }
  sort(que + 1, que + Q + 1);
  int pnt = 1;
  Build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    if (pos[i]) Modify(1, 1, n, 1, pos[i], pos[i], i);
    while (pnt <= Q && que[pnt].r == i)
      ans[que[pnt].idx] = Query(1, 1, n, que[pnt].l), pnt++;
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
