#include <bits/stdc++.h>
using namespace std;
const int N = 1e5, oo = 1e6;
int seg[4 * N], n, m, lazy[4 * N], ans[N];
vector<int> v[N];
struct query {
  int r, id;
  query(int a = 0, int b = 0) {
    r = a;
    id = b;
  }
};
vector<query> q[N];
void fix(int c, int l, int r) {
  seg[c] = min(seg[c], lazy[c]);
  if (l != r) {
    lazy[2 * c + 1] = min(lazy[2 * c + 1], lazy[c]);
    lazy[2 * c + 2] = min(lazy[2 * c + 2], lazy[c]);
  }
  lazy[c] = oo;
}
void update(int c, int l, int r, int s, int e, int val) {
  fix(c, l, r);
  if (l > e || r < s) return;
  if (l >= s && r <= e) {
    lazy[c] = val;
    fix(c, l, r);
    return;
  }
  update(2 * c + 1, l, (l + r) / 2, s, e, val);
  update(2 * c + 2, (l + r) / 2 + 1, r, s, e, val);
  seg[c] = max(seg[2 * c + 1], seg[2 * c + 2]);
}
int get(int c, int l, int r, int s, int e, int val) {
  fix(c, l, r);
  if (l > e || r < s) return -1;
  if (l >= s && r <= e)
    if (seg[c] <= val) return -1;
  if (l == r) return l;
  int temp = get(2 * c + 1, l, (l + r) / 2, s, e, val);
  if (temp != -1) return temp;
  return get(2 * c + 2, (l + r) / 2 + 1, r, s, e, val);
}
int main() {
  for (int i = 0; i < 4 * N; i++) seg[i] = lazy[i] = oo;
  scanf("%d%d", &n, &m);
  for (int i = 0, l, r; i < m; i++) {
    scanf("%d%d", &l, &r);
    if (l == r) continue;
    v[l - 1].push_back(r - 1);
  }
  scanf("%d", &m);
  for (int i = 0, l, r; i < m; i++) {
    scanf("%d%d", &l, &r);
    q[l - 1].push_back(query(r - 1, i));
  }
  for (int i = n - 1; i + 1; i--) {
    for (auto j : v[i]) update(0, 0, n - 1, i, j - 1, j);
    for (auto j : q[i]) ans[j.id] = get(0, 0, n - 1, i, n - 1, j.r);
  }
  for (int i = 0; i < m; i++) printf("%d\n", ans[i] + 1);
}
