#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 17, TOUR = 1 << 17, LG = 18;
set<pair<int, int> > t[2 * TOUR];
int presjek(pair<int, int> a, pair<int, int> b) {
  return max(a.first, b.first) <= min(a.second, b.second);
}
void ubaci(set<pair<int, int> > &S, pair<int, int> val) {
  auto it = S.lower_bound({val.first, -1});
  for (; it != S.begin() && (it == S.end() || it->first > val.first); it--)
    ;
  for (; it != S.end();) {
    if (presjek(*it, val)) {
      val.first = min(val.first, it->first);
      val.second = max(val.second, it->second);
      auto it2 = it++;
      S.erase(it2);
    } else if (it->first < val.first)
      it++;
    else
      break;
  }
  S.insert(val);
}
void insert(int pos, pair<int, int> val) {
  pos += TOUR;
  for (; pos; pos /= 2) ubaci(t[pos], val);
}
int eval(set<pair<int, int> > &S, int val) {
  auto it = S.lower_bound(pair<int, int>(val, val));
  for (; it != S.begin() && (it == S.end() || it->first > val); it--)
    ;
  if (it != S.end() && it->first <= val) return max(val, it->second);
  return val;
}
void q(int pos, int lo, int hi, int begin, int &val) {
  if (hi <= begin) return;
  if (lo >= begin) {
    val = eval(t[pos], val);
    return;
  }
  q(2 * pos + 0, lo, (lo + hi) / 2, begin, val);
  q(2 * pos + 1, (lo + hi) / 2, hi, begin, val);
}
pair<int, int> p[MAX];
pair<pair<int, int>, int> kver[MAX];
int rje[MAX];
int main() {
  int n;
  scanf("%*d%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
  }
  sort(p, p + n,
       [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });
  int brq;
  scanf("%d", &brq);
  for (int i = 0; i < brq; i++) {
    scanf("%d%d", &kver[i].first.first, &kver[i].first.second);
    kver[i].second = i;
  }
  sort(kver, kver + brq,
       [](pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
         return a.first.second < b.first.second;
       });
  int indp = 0;
  for (int i = 0; i < brq; i++) {
    for (; indp < n && p[indp].second <= kver[i].first.second; indp++)
      insert(p[indp].first, p[indp]);
    rje[kver[i].second] = kver[i].first.first;
    q(1, 0, TOUR, kver[i].first.first, rje[kver[i].second]);
  }
  for (int i = 0; i < brq; i++) printf("%d\n", rje[i]);
  return 0;
}
