#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int r, c, n; cin >> r >> c >> n;
	set<int> st[r + 1];
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		st[x].insert(y);
	}
	
	int t; cin >> t;
	while (t--) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (x2 < x1 || y2 < y1) {
			cout << "No\n";
			continue;
		}
		
		int cur = y1; bool b = 1;
		for (int i = x1; i < x2; i++) {
			auto it = st[i].lower_bound(cur);
			if (it == st[i].end()) {
				b = 0;
				break;
			}
			cur = *it;
			if (cur > y2) {
				b = 0;
				break;
			}
		}
		cout << (b ? "Yes\n" : "No\n");
	}
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |