#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
struct line {
  int a, b;
  line() {}
  line(int a, int b) : a(a), b(b) {}
  bool operator<(const line& o) const { return a < o.a; }
  friend line operator+(const line& first, const line& second) {
    if (second < first) return second + first;
    if (first.b >= second.a && first.b < second.b)
      return line(first.a, second.b);
    return first;
  }
  void print() { printf("(%d, %d) ", a, b); }
};
struct node {
  vector<line> box;
  node() {}
  node(line first) { box = {first}; }
  int size() { return (int)(box).size(); }
  friend node operator+(const node& X, const node& Y) {
    const vector<line>& first = X.box;
    const vector<line>& second = Y.box;
    int l = 0, r = 0;
    node T;
    vector<line>& t = T.box;
    while (l < first.size() && r < second.size()) {
      if (first[l] < second[r])
        t.push_back(first[l++]);
      else
        t.push_back(second[r++]);
    }
    while (l < first.size()) t.push_back(first[l++]);
    while (r < second.size()) t.push_back(second[r++]);
    vector<line> Stack;
    Stack.push_back(t.back());
    for (int i = ((int)(t).size() - 2); i >= (0); --i) {
      line& c = t[i];
      while (!Stack.empty() && Stack.back().a <= c.b) {
        c.b = max(c.b, Stack.back().b);
        Stack.pop_back();
      }
      Stack.push_back(c);
    }
    Stack.clear();
    return T;
  }
  line search(int a) {
    int l = 0, r = size();
    while (l < r) {
      int m = (l + r) >> 1;
      if (box[m].a < a)
        l = m + 1;
      else
        r = m;
    }
    if (l != size()) return box[l];
    return line(inf, inf);
  }
  void print() {
    printf("{ ");
    for (line& e : box) {
      e.print();
      cout << " ";
    }
    printf("}\n");
  }
};
const int N = 100005;
line rope[N];
node seg[N << 2];
void build(int l, int r, int now) {
  if (l == r) {
    seg[now] = node(rope[l]);
    return;
  }
  int m = (l + r) >> 1;
  int L = (now << 1), R = (now << 1 | 1);
  build(l, m, L);
  build(m + 1, r, R);
  seg[now] = seg[L] + seg[R];
}
line get(int ll, int rr, int l, int r, int now) {
  if (ll <= l && r <= rr) {
    return seg[now].search(ll);
  }
  if (rr < l || r < ll) return line(inf, inf);
  int m = (l + r) >> 1;
  return get(ll, rr, l, m, now << 1) + get(ll, rr, m + 1, r, now << 1 | 1);
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    int a, b;
    cin >> a >> b;
    rope[b] = {a, b};
  }
  build(1, n, 1);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    line ans = get(a, b, 1, n, 1);
    if (ans.a != a)
      printf("%d\n", a);
    else
      printf("%d\n", ans.b);
  }
}
int main() {
  solve();
  return 0;
}
