#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int INF = 1<<29;
const int MAX_N = 510000;

typedef long long VAL;
typedef long long DELAY;

const VAL UNITY_VAL = INF;
const DELAY UNITY_DELAY = 0;

static int SIZE_SEG;
struct SegTree {
    VAL val[4*MAX_N];        // min
    DELAY delay[4*MAX_N];    // +
    
    void init(int n = MAX_N, VAL v = UNITY_VAL, DELAY dv = UNITY_DELAY) {
        SIZE_SEG = 1;
        while (SIZE_SEG < n) SIZE_SEG *= 2;
        for (int i = 0; i < 2*SIZE_SEG-1; ++i) val[i] = v, delay[i] = dv;
    }
    
    inline void init_set(int a, VAL x) {
        a += SIZE_SEG-1; val[a] = x;
    }
    
    inline void init_tree(int k = 0, int l = 0, int r = SIZE_SEG) {
        if (r - l == 1) {}                      // leaf
        else {
            init_tree(k*2+1, l, (l+r)/2);
            init_tree(k*2+2, (l+r)/2, r);
            val[k] = merge(val[k*2+1], val[k*2+2]);
        }
    }
    
    inline VAL merge(VAL a, VAL b) {
        VAL res = min(a, b);
        return res;
    }
    
    inline void add(DELAY &d, DELAY x) {
	  d += x; // d.f += x.f;
    }
    
    inline void reflect(VAL &a, DELAY d, int l, int r) {
	  a += d;
        // a.f += d.f * (r-l);
    }
    
    inline void redelay(int k, int l, int r) {
        reflect(val[k], delay[k], l, r);
        if (k < SIZE_SEG-1) {
            add(delay[k*2+1], delay[k]);
            add(delay[k*2+2], delay[k]);
        }
        delay[k] = UNITY_DELAY;
    }
    
    inline void renode(int k, int l, int r) {
        val[k] = merge(val[k*2+1], val[k*2+2]);
    }
    
    inline void set(int a, int b, DELAY x, int k = 0, int l = 0, int r = SIZE_SEG) {
        if (a <= l && r <= b) {                 // included
            add(delay[k], x);
            redelay(k, l, r);
        }
        else if (a < r && l < b) {              // intersected
            redelay(k, l, r);
            set(a, b, x, k*2+1, l, (l+r)/2);
            set(a, b, x, k*2+2, (l+r)/2, r);
            renode(k, l, r);
        }
        else {                                  // no-intersected
            redelay(k, l, r);
        }
    }
    
    inline VAL get(int a, int b, int k = 0, int l = 0, int r = SIZE_SEG) {
        redelay(k, l, r);
        if (a <= l && r <= b) {                 // included
            return val[k];
        }
        else if (a < r && l < b) {              // intersected
            VAL t1 = get(a, b, k*2+1, l, (l+r)/2);
            VAL t2 = get(a, b, k*2+2, (l+r)/2, r);
            renode(k, l, r);
            
            return merge(t1, t2);
        }
        else {                                  // no-intersected
            return UNITY_VAL;
        }
    }
    
    inline VAL operator [] (int i) {return get(i, i+1);}
    
    void print(long long r = SIZE_SEG) {
        long long t = 2;
        for (int i = 0; i < r*2-1; ++i) {
            cout << make_pair(val[i], delay[i]) << ",";
            if (i == t-2) {cout << endl; t *= 2;}
        }
        for (int i = 0; i < r; ++i) {
            cout << get(i, i+1) << ", ";
        }
        cout << endl << endl;
    }
} seg;


typedef pair<int,int> pint;


int N, M, Q;
vector<pair<int,pint> > el;
vector<pair<pair<int,pint>, int> > qu;
vector<string> res;

int main() {
  while (cin >> N >> M >> Q) {
	el.clear();
	qu.clear();
	res.clear();
	res.resize(Q);

	for (int i = 0; i < M; ++i) {
	  int d, a, b;
	  cin >> d >> a >> b;
	  --a, --b;
	  //++b;
	  el.push_back(make_pair(d, pint(a, b)) );
	}
	for (int q = 0; q < Q; ++q) {
	  int e, s, t;
	  cin >> e >> s >> t;
	  --s, --t;
	  qu.push_back(make_pair( make_pair(e, pint(s, t)), q) );
	}

	sort(el.begin(), el.end());
	sort(qu.begin(), qu.end());

	/*
	COUT(el);
	COUT(qu);
	*/

	seg.init(N + 5, 0, 0);
	int j = 0;
	for (int i = 0; i < qu.size(); ++i) {
	  int e = qu[i].first.first;
	  int s = qu[i].first.second.first;
	  int t = qu[i].first.second.second;
	  int q = qu[i].second;

	  

	  for (; j < el.size(); ++j) {
		int d = el[j].first;
		int a = el[j].second.first;
		int b = el[j].second.second;
		if (d >= e) {
		  break;
		}
		seg.set(a, b, 1);
	  }


	  if (t <= s) {
		res[q] = "Yes";
		continue;
	  }
					
	  
	  int Min = seg.get(s, t);

	  /*
	  COUT(i);
	  COUT(j);
	  seg.print();
	  COUT(Min);
	  */

	  if (Min > 0) res[q] = "Yes";
	  else res[q] = "No";
	}

	for (int q = 0; q < Q; ++q) {
	  cout << res[q] << endl;
	}
  }
}


















### Prompt

Construct a Cpp code solution to the problem outlined:

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
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int INF = 1<<29;
const int MAX_N = 510000;

typedef long long VAL;
typedef long long DELAY;

const VAL UNITY_VAL = INF;
const DELAY UNITY_DELAY = 0;

static int SIZE_SEG;
struct SegTree {
    VAL val[4*MAX_N];        // min
    DELAY delay[4*MAX_N];    // +
    
    void init(int n = MAX_N, VAL v = UNITY_VAL, DELAY dv = UNITY_DELAY) {
        SIZE_SEG = 1;
        while (SIZE_SEG < n) SIZE_SEG *= 2;
        for (int i = 0; i < 2*SIZE_SEG-1; ++i) val[i] = v, delay[i] = dv;
    }
    
    inline void init_set(int a, VAL x) {
        a += SIZE_SEG-1; val[a] = x;
    }
    
    inline void init_tree(int k = 0, int l = 0, int r = SIZE_SEG) {
        if (r - l == 1) {}                      // leaf
        else {
            init_tree(k*2+1, l, (l+r)/2);
            init_tree(k*2+2, (l+r)/2, r);
            val[k] = merge(val[k*2+1], val[k*2+2]);
        }
    }
    
    inline VAL merge(VAL a, VAL b) {
        VAL res = min(a, b);
        return res;
    }
    
    inline void add(DELAY &d, DELAY x) {
	  d += x; // d.f += x.f;
    }
    
    inline void reflect(VAL &a, DELAY d, int l, int r) {
	  a += d;
        // a.f += d.f * (r-l);
    }
    
    inline void redelay(int k, int l, int r) {
        reflect(val[k], delay[k], l, r);
        if (k < SIZE_SEG-1) {
            add(delay[k*2+1], delay[k]);
            add(delay[k*2+2], delay[k]);
        }
        delay[k] = UNITY_DELAY;
    }
    
    inline void renode(int k, int l, int r) {
        val[k] = merge(val[k*2+1], val[k*2+2]);
    }
    
    inline void set(int a, int b, DELAY x, int k = 0, int l = 0, int r = SIZE_SEG) {
        if (a <= l && r <= b) {                 // included
            add(delay[k], x);
            redelay(k, l, r);
        }
        else if (a < r && l < b) {              // intersected
            redelay(k, l, r);
            set(a, b, x, k*2+1, l, (l+r)/2);
            set(a, b, x, k*2+2, (l+r)/2, r);
            renode(k, l, r);
        }
        else {                                  // no-intersected
            redelay(k, l, r);
        }
    }
    
    inline VAL get(int a, int b, int k = 0, int l = 0, int r = SIZE_SEG) {
        redelay(k, l, r);
        if (a <= l && r <= b) {                 // included
            return val[k];
        }
        else if (a < r && l < b) {              // intersected
            VAL t1 = get(a, b, k*2+1, l, (l+r)/2);
            VAL t2 = get(a, b, k*2+2, (l+r)/2, r);
            renode(k, l, r);
            
            return merge(t1, t2);
        }
        else {                                  // no-intersected
            return UNITY_VAL;
        }
    }
    
    inline VAL operator [] (int i) {return get(i, i+1);}
    
    void print(long long r = SIZE_SEG) {
        long long t = 2;
        for (int i = 0; i < r*2-1; ++i) {
            cout << make_pair(val[i], delay[i]) << ",";
            if (i == t-2) {cout << endl; t *= 2;}
        }
        for (int i = 0; i < r; ++i) {
            cout << get(i, i+1) << ", ";
        }
        cout << endl << endl;
    }
} seg;


typedef pair<int,int> pint;


int N, M, Q;
vector<pair<int,pint> > el;
vector<pair<pair<int,pint>, int> > qu;
vector<string> res;

int main() {
  while (cin >> N >> M >> Q) {
	el.clear();
	qu.clear();
	res.clear();
	res.resize(Q);

	for (int i = 0; i < M; ++i) {
	  int d, a, b;
	  cin >> d >> a >> b;
	  --a, --b;
	  //++b;
	  el.push_back(make_pair(d, pint(a, b)) );
	}
	for (int q = 0; q < Q; ++q) {
	  int e, s, t;
	  cin >> e >> s >> t;
	  --s, --t;
	  qu.push_back(make_pair( make_pair(e, pint(s, t)), q) );
	}

	sort(el.begin(), el.end());
	sort(qu.begin(), qu.end());

	/*
	COUT(el);
	COUT(qu);
	*/

	seg.init(N + 5, 0, 0);
	int j = 0;
	for (int i = 0; i < qu.size(); ++i) {
	  int e = qu[i].first.first;
	  int s = qu[i].first.second.first;
	  int t = qu[i].first.second.second;
	  int q = qu[i].second;

	  

	  for (; j < el.size(); ++j) {
		int d = el[j].first;
		int a = el[j].second.first;
		int b = el[j].second.second;
		if (d >= e) {
		  break;
		}
		seg.set(a, b, 1);
	  }


	  if (t <= s) {
		res[q] = "Yes";
		continue;
	  }
					
	  
	  int Min = seg.get(s, t);

	  /*
	  COUT(i);
	  COUT(j);
	  seg.print();
	  COUT(Min);
	  */

	  if (Min > 0) res[q] = "Yes";
	  else res[q] = "No";
	}

	for (int q = 0; q < Q; ++q) {
	  cout << res[q] << endl;
	}
  }
}


















```