#include <bits/stdc++.h>
using namespace std;
template <typename T>
void in(T &x) {
  T c = getchar();
  while (((c < 48) || (c > 57)) && (c != '-')) c = getchar();
  bool neg = false;
  if (c == '-') neg = true;
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x * 10) + (c - 48);
  if (neg) x = -x;
}
const int MAXN = 1e5 + 100;
const int MAGIC = 330;
int from[MAXN];
pair<int, int> ropes[MAXN];
int go[MAXN][MAGIC];
int to[MAXN][MAGIC];
int n, q, ht;
int k;
inline void smax(int &a, int b) { a = max(a, b); }
inline void smin(int &a, int b) { a = min(a, b); }
int main() {
  in(ht);
  k = sqrt(ht);
  in(n);
  for (int i = 1; i <= n; i++) {
    in(ropes[i].first), in(ropes[i].second);
    from[ropes[i].second] = ropes[i].first;
    smax(to[ropes[i].first][1 + (ropes[i].second - 1) / k], ropes[i].second);
  }
  for (int i = 1; i <= ht; i++) {
    for (int j = 1; j * k <= ht; j++) {
      smax(to[i][j], to[i][j - 1]);
    }
  }
  for (int j = 1; j * k <= ht; j++) {
    stack<int> s;
    for (int i = j * k; i > 0; i--) {
      go[i][j] = to[i][j];
      while (s.size() && s.top() <= to[i][j]) {
        smax(go[i][j], go[s.top()][j]);
        s.pop();
      }
      s.push(i);
    }
  }
  int q, x, y;
  in(q);
  while (q--) {
    in(x), in(y);
    int res = x;
    int up_k = (y - 1) / k;
    smax(res, go[x][up_k]);
    for (int i = up_k * k + 1; i <= y; i++) {
      if (from[i] <= res && from[i] >= x) {
        res = i;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
