#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MAX = 100100;
vector<pair<pair<int, int>, int> > Q[MAX];
int ANS[MAX];
struct DSU {
  int p[MAX];
  int sz[MAX];
  int L[MAX];
  int R[MAX];
  void init(int n) {
    for (int i = (0); i < (n); i++) sz[i] = 1, p[i] = L[i] = R[i] = i;
  }
  int get(int a) { return p[a] == a ? a : p[a] = get(p[a]); }
  void unite(int a, int b) {
    a = get(a);
    b = get(b);
    if (a == b) return;
    if (sz[a] < sz[b]) swap(a, b);
    p[b] = a;
    L[a] = min(L[a], L[b]);
    R[a] = max(R[a], R[b]);
    sz[a] += sz[b];
  }
} D;
int L[MAX];
vector<int> R[MAX];
const int MAGIC = 333;
int n;
void solve(vector<pair<pair<int, int>, int> > Q) {
  if (Q.empty()) return;
  sort(Q.begin(), Q.end());
  reverse(Q.begin(), Q.end());
  D.init(n);
  int bind = Q[0].first.second / MAGIC * MAGIC;
  int ll = bind - 1;
  for (int i = (0); i < ((int)Q.size()); i++) {
    int l = Q[i].first.first;
    int r = Q[i].first.second;
    int ind = Q[i].second;
    while (ll >= l) {
      for (int j = (0); j < ((int)R[ll].size()); j++) {
        int pos = ll;
        int to = R[ll][j];
        if (to >= bind) continue;
        while (pos < to) {
          D.unite(pos, pos + 1);
          pos = D.R[D.get(pos)];
        }
      }
      ll--;
    }
    int bst = D.R[D.get(l)];
    for (int j = (bind); j < (r + 1); j++) {
      if (L[j] <= bst && L[j] >= l) {
        bst = j;
      }
    }
    ANS[ind] = bst;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m;
  cin >> n >> m;
  for (int i = (0); i < (n); i++) L[i] = i;
  for (int i = (0); i < (m); i++) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    L[r] = l;
    R[l].push_back(r);
  }
  int q;
  cin >> q;
  for (int i = (0); i < (q); i++) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    Q[r / MAGIC].push_back(make_pair(make_pair(l, r), i));
  }
  for (int i = (0); i < (n); i++) {
    solve(Q[i]);
  }
  for (int i = (0); i < (q); i++) {
    cout << ANS[i] + 1 << "\n";
  }
}
