func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace thecold {   inline int read() {     int res = 0;     bool flag = false;     char c = getchar();     while (!isdigit(c)) flag = (c ==  - ), c = getchar();     while (isdigit(c)) res = res * 10 + (c ^ 48), c = getchar();     return !flag ? res : -res;   }   const int Max_n = 1e5 + 5;   int bak[Max_n], n, m, q;   struct node {     int l, r, tagl, tagv, mx, mmx;     node(int a, int b) { l = a, r = b, tagv = tagl = mx = mmx = 0; }     node() {}   } tree[Max_n << 3];   inline void push_up(const int tr) {     int ls = tr << 1, rs = tr << 1 | 1;     if (tree[tr].l == tree[tr].r) return;     if (tree[ls].mx > tree[rs].mx)       tree[tr].mx = tree[ls].mx, tree[tr].mmx = max(tree[ls].mmx, tree[rs].mx);     else if (tree[ls].mx < tree[rs].mx)       tree[tr].mx = tree[rs].mx, tree[tr].mmx = max(tree[ls].mx, tree[rs].mmx);     else       tree[tr].mx = tree[ls].mx, tree[tr].mmx = max(tree[ls].mmx, tree[rs].mmx);   }   inline void build(const int l, const int r, const int tr) {     tree[tr] = node(l, r);     if (l == r) return tree[tr].mx = l, tree[tr].mmx = -Max_n, void();     int mid = (l + r) >> 1;     build(l, mid, tr << 1), build(mid + 1, r, tr << 1 | 1);     push_up(tr);   }   inline void cop(node &a, node b, const int tr) {     a.mx = a.tagv = b.tagv, !a.tagl && (a.tagl = b.tagl);   }   inline void push_down(const int tr) {     if (!tree[tr].tagl) return;     int ls = tr << 1, rs = tr << 1 | 1;     if (tree[ls].mx == tree[tr].tagl) cop(tree[ls], tree[tr], tr);     if (tree[rs].mx == tree[tr].tagl) cop(tree[rs], tree[tr], tr);     tree[tr].tagl = tree[tr].tagv = 0;   }   inline void change(const int l, const int r, const int va, const int lim,                      const int tr) {     int ll = tree[tr].l, rr = tree[tr].r;     if (ll > r || rr < l) return;     if (tree[tr].mx < lim) return;     push_down(tr);     if (l <= ll && rr <= r) {       if (tree[tr].mmx < lim)         return tree[tr].tagl = tree[tr].mx, tree[tr].tagv = tree[tr].mx = va,                void();     }     change(l, r, va, lim, tr << 1), change(l, r, va, lim, tr << 1 | 1);     push_up(tr);   }   int ans[Max_n];   struct Node {     int l, bel;     Node(int a, int b) { l = a, bel = b; }     Node() {}   };   vector<Node> v[Max_n];   inline int query(const int pos, const int tr) {     int ll = tree[tr].l, rr = tree[tr].r;     if (ll == rr) return tree[tr].mx;     push_down(tr);     int mid = (ll + rr) >> 1;     if (mid >= pos) return query(pos, tr << 1);     return query(pos, tr << 1 | 1);   }   inline void main() {     n = read(), m = read();     build(1, n, 1);     for (int i = 1; i <= m; ++i) {       int ui = read(), vi = read();       bak[vi] = ui;     }     q = read();     for (int i = 1; i <= q; ++i) {       int li = read(), ri = read();       v[ri].push_back(Node(li, i));     }     for (int now = 1; now <= n; ++now) {       if (bak[now]) change(1, bak[now], now, bak[now], 1);       int sz = v[now].size();       for (int i = 0; i < sz; ++i) ans[v[now][i].bel] = query(v[now][i].l, 1);     }     for (int i = 1; i <= q; ++i) printf( %d n , ans[i]);   }   }  // namespace thecold   int main() {     thecold::main();     return 0;   }   