#include <bits/stdc++.h>
using namespace std;
const int M = 400;
int f[100010][310];
int to[100010][310];
int pos[100010];
int s[100010];
int solve(int l, int r) {
  int p = r / M;
  int x = l;
  if (p * M >= l) x = f[l][p];
  p = max(p * M, l);
  for (int i = p + 1; i <= r; i++)
    if (l <= pos[i] && pos[i] <= x) x = i;
  return x;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    pos[r] = l;
    for (int j = 1; j * M <= n; j++)
      if (r <= j * M) to[l][j] = max(to[l][j], r);
  }
  for (int j = 1; j * M <= n; j++) {
    int r = j * M;
    int head = 0;
    for (int l = r; l >= 1; l--) {
      f[l][j] = l;
      while (head && s[head] <= to[l][j]) {
        f[l][j] = max(f[l][j], f[s[head]][j]);
        head--;
      }
      s[++head] = l;
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%d\n", solve(l, r));
  }
  return 0;
}
