func_code_string: #include <bits/stdc++.h>   using namespace std;   struct query {     int en, ll, rr, ind;   };   int tr[3][3000000], mx, h, w, n, m, ok[400000];   vector<int> vrx[300000], vry[300000];   vector<query> qrx[300000], qry[300000];   void build(int x, int l, int r, int tp) {     if (l == r) {       tr[tp][x] = 300000;       return;     }     int mid = (r + l) / 2;     build(x * 2, l, mid, tp);     build(x * 2 + 1, mid + 1, r, tp);     tr[tp][x] = max(tr[tp][x * 2], tr[tp][x * 2 + 1]);   }   void md(int x, int l, int r, int ll, int y, int tp) {     if (l == r) {       tr[tp][x] = y;       return;     }     int mid = (r + l) / 2;     if (ll <= mid)       md(x * 2, l, mid, ll, y, tp);     else       md(x * 2 + 1, mid + 1, r, ll, y, tp);     tr[tp][x] = max(tr[tp][x * 2], tr[tp][x * 2 + 1]);   }   void findmx(int x, int l, int r, int ll, int rr, int tp) {     if (ll <= l && r <= rr) {       if (mx < tr[tp][x]) mx = tr[tp][x];       return;     }     int mid = (r + l) / 2;     if (ll <= mid) findmx(x * 2, l, mid, ll, rr, tp);     if (rr > mid) findmx(x * 2 + 1, mid + 1, r, ll, rr, tp);     tr[tp][x] = max(tr[tp][x * 2], tr[tp][x * 2 + 1]);   }   int main() {     ios_base::sync_with_stdio(0);     cin >> h >> w >> n >> m;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       vrx[x].push_back(y);       vry[y].push_back(x);     }     for (int i = 1; i <= m; i++) {       int xb, yb, xe, ye;       cin >> xb >> yb >> xe >> ye;       qrx[xb].push_back((query){xe, yb, ye, i});       qry[yb].push_back((query){ye, xb, xe, i});     }     build(1, 1, h, 0);     build(1, 1, w, 1);     for (int i = h; i >= 1; i--) {       for (int j = 0; j < vrx[i].size(); j++) {         int y = vrx[i][j];         md(1, 1, w, y, i, 1);       }       for (int j = 0; j < qrx[i].size(); j++) {         int y = qrx[i][j].en;         int l = qrx[i][j].ll;         int r = qrx[i][j].rr;         int sl = qrx[i][j].ind;         mx = 0;         findmx(1, 1, w, l, r, 1);         if (mx <= y) ok[sl] = 1;       }     }     for (int i = w; i >= 1; i--) {       for (int j = 0; j < vry[i].size(); j++) {         int x = vry[i][j];         md(1, 1, h, x, i, 0);       }       for (int j = 0; j < qry[i].size(); j++) {         int x = qry[i][j].en;         int l = qry[i][j].ll;         int r = qry[i][j].rr;         int sl = qry[i][j].ind;         mx = 0;         findmx(1, 1, h, l, r, 0);         if (mx <= x) ok[sl] = 1;       }     }     for (int i = 1; i <= m; i++)       if (ok[i] == 1)         cout <<  YES n ;       else         cout <<  NO n ;     return 0;   }   