#define ll long long
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
struct qq{
	int id, d, fr, to;
	int stt;
};
const int N = 500000;
qq que[N];
int t, m, q, a, b, dd, k = 0;
 map<int, int> invals;
void addRange(int left, int right) {
        auto l = invals.upper_bound(left), r = invals.upper_bound(right); 
        if (l != invals.begin()) {
            l--;
            if (l->second < left) l++;
        }
        if (l != r) {
            left = min(left, l->first);
            right = max(right, (--r)->second);
            invals.erase(l,++r);
        }
        invals[left] = right;
    }
    
    bool queryRange(int left, int right) {
        auto it = invals.upper_bound(left);
        if (it == invals.begin() || (--it)->second < right) return false;
        return true;
    }
    
    void removeRange(int left, int right) {
        auto l = invals.upper_bound(left), r = invals.upper_bound(right); 
        if (l != invals.begin()) {
            l--;
            if (l->second < left) l++;
        }
        if (l == r) return;
        int l1 = min(left, l->first), r1 = max(right, (--r)->second);
        invals.erase(l, ++r);
        if (l1 < left) invals[l1] = left;
        if (r1 > right) invals[right] = r1;
    }
bool cmp(qq a, qq b){
	if(a.d != b.d) return a.d < b.d;
	return a.id < b.id;
}
void solve(){
	invals.clear();
	k = 0;
		scanf("%d%d%d", &t, &m, &q);
	for(int i = 0; i < m ; i++){
		scanf("%d%d%d", &dd, &a, &b);
		que[k].id = 1; que[k].d = dd + 1; que[k].fr = a; que[k].to = b;
		k++;
	}
	for(int i = 0; i < q; i++){
		scanf("%d%d%d", &dd, &a, &b);
		que[k].id = 2; que[k].d = dd; que[k].fr = a; que[k].to = b;
		que[k].stt = i;
		k++;
	}
	sort(que, que + k, cmp);
	bool ans[q]; memset(ans, 0, sizeof ans);
	for(int i = 0; i < k; i++){
		if(que[i].id == 1){
			addRange(que[i].fr, que[i].to);
		}else{
			if(queryRange(que[i].fr, que[i].to) || que[i].fr >= que[i].to){
				ans[que[i].stt] = true;
			}else ans[que[i].stt] = false;
		}
	}
	for(int i = 0; i < q; i++){
		if(ans[i]) printf("Yes\n");
		else printf("No\n");
	}
}
int main(){
	solve();
	return 0;
}

### Prompt

Generate a CPP solution to the following problem:

problem

AOR Co., Ltd. is a $ N $ story building. There is no basement floor.
AOR Ika-chan is a squid, so she can go down the stairs, but not up.

I decided to install $ M $ elevators in the building because it would be inconvenient if I couldn't climb upstairs.
It takes time to install the elevator, and the $ i $ th elevator will be installed the night after $ D_i $ and will be mobile on all floors above the $ A_i $ floor and below the $ B_i $ floor.

You were asked $ Q $ questions by AOR Ika-chan. The $ i $ th question is, "Can I move from the $ S_i $ floor to the $ T_i $ floor at noon $ E_i $ days later?"
The only means of transportation are stairs and elevators. In addition, the time required for movement shall be negligible.



input

$ N \ M \ Q $
$ D_1 \ A_1 \ B_1 $
$ \ vdots $
$ D_M \ A_M \ B_M $
$ E_1 \ S_1 \ T_1 $
$ \ vdots $
$ E_Q \ S_Q \ T_Q $

output

Print Yes or No on one line for each question. However, answer in the order in which they are asked. Also, output a line break at the end.

Example

Input

5 1 2
3 1 5
3 1 5
4 1 5


Output

No
Yes

### Response

```cpp
#define ll long long
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
struct qq{
	int id, d, fr, to;
	int stt;
};
const int N = 500000;
qq que[N];
int t, m, q, a, b, dd, k = 0;
 map<int, int> invals;
void addRange(int left, int right) {
        auto l = invals.upper_bound(left), r = invals.upper_bound(right); 
        if (l != invals.begin()) {
            l--;
            if (l->second < left) l++;
        }
        if (l != r) {
            left = min(left, l->first);
            right = max(right, (--r)->second);
            invals.erase(l,++r);
        }
        invals[left] = right;
    }
    
    bool queryRange(int left, int right) {
        auto it = invals.upper_bound(left);
        if (it == invals.begin() || (--it)->second < right) return false;
        return true;
    }
    
    void removeRange(int left, int right) {
        auto l = invals.upper_bound(left), r = invals.upper_bound(right); 
        if (l != invals.begin()) {
            l--;
            if (l->second < left) l++;
        }
        if (l == r) return;
        int l1 = min(left, l->first), r1 = max(right, (--r)->second);
        invals.erase(l, ++r);
        if (l1 < left) invals[l1] = left;
        if (r1 > right) invals[right] = r1;
    }
bool cmp(qq a, qq b){
	if(a.d != b.d) return a.d < b.d;
	return a.id < b.id;
}
void solve(){
	invals.clear();
	k = 0;
		scanf("%d%d%d", &t, &m, &q);
	for(int i = 0; i < m ; i++){
		scanf("%d%d%d", &dd, &a, &b);
		que[k].id = 1; que[k].d = dd + 1; que[k].fr = a; que[k].to = b;
		k++;
	}
	for(int i = 0; i < q; i++){
		scanf("%d%d%d", &dd, &a, &b);
		que[k].id = 2; que[k].d = dd; que[k].fr = a; que[k].to = b;
		que[k].stt = i;
		k++;
	}
	sort(que, que + k, cmp);
	bool ans[q]; memset(ans, 0, sizeof ans);
	for(int i = 0; i < k; i++){
		if(que[i].id == 1){
			addRange(que[i].fr, que[i].to);
		}else{
			if(queryRange(que[i].fr, que[i].to) || que[i].fr >= que[i].to){
				ans[que[i].stt] = true;
			}else ans[que[i].stt] = false;
		}
	}
	for(int i = 0; i < q; i++){
		if(ans[i]) printf("Yes\n");
		else printf("No\n");
	}
}
int main(){
	solve();
	return 0;
}

```