#include <bits/stdc++.h>
using namespace std;
const int N = 100005, B = 321;
inline void read(int &x) {
  x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int n, m, top, Q, go[N], to[N], s[N], dp[321][N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    read(x);
    read(y);
    go[y] = x;
  }
  for (int i = 1; i * B <= n; i++) {
    for (int j = (i - 1) * B + 1; j <= i * B; j++) to[go[j]] = j;
    top = 0;
    for (int j = i * B; j; j--) {
      dp[i][j] = j;
      while (top && s[top] <= to[j]) {
        dp[i][j] = dp[i][s[top]];
        top--;
      }
      s[++top] = j;
    }
  }
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int x, y, k;
    read(x);
    read(y);
    if (x <= y / B * B)
      k = dp[y / B][x];
    else
      k = x;
    for (int j = max(y / B * B + 1, x); j <= y; j++)
      if (go[j] >= x && go[j] <= k) k = j;
    printf("%d\n", k);
  }
  return 0;
}
