/*  -*- coding: utf-8 -*-
 *
 * 2880.cc: Elevator
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_E2 = 1 << 18; // = 262144
const int MAX_M = 100000;
const int MAX_Q = 100000;
const int MAX_K = MAX_M + MAX_Q;
const int INF = 1 << 30;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T nodes[MAX_E2], inf;
  bool ds[MAX_E2];
  SegTreeMin() {}

  void init(int _n, T _inf) {
    n = _n, inf = _inf;
    for (e2 = 1; e2 < n; e2 <<= 1);
    //fill(nodes, nodes + MAX_E2, inf);
  }

  T get(int i) { return nodes[e2 - 1 + i]; }

  void set_range(int r0, int r1, T v, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return;
    if (r0 <= i0 && i1 <= r1) {
      nodes[k] = v;
      ds[k] = true;
      return;
    }

    int k0 = k * 2 + 1, k1 = k0 + 1;
    if (ds[k]) {
      nodes[k0] = nodes[k1] = nodes[k];
      ds[k0] = ds[k1] = true;
      ds[k] = false;
    }

    int im = (i0 + i1) / 2;
    set_range(r0, r1, v, k0, i0, im);
    set_range(r0, r1, v, k1, im, i1);
    nodes[k] = min(nodes[k0], nodes[k1]);
  }
  void set_range(int r0, int r1, T v) { set_range(r0, r1, v, 0, 0, e2); }
  
  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return inf;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int k0 = k * 2 + 1, k1 = k0 + 1;
    if (ds[k]) {
      nodes[k0] = nodes[k1] = nodes[k];
      ds[k0] = ds[k1] = true;
      ds[k] = false;
    }

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k0, i0, im);
    T v1 = min_range(r0, r1, k1, im, i1);

    return min(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

struct Event {
  int d, t, a, b, i;
  Event() {}
  Event(int _d, int _t, int _a, int _b, int _i):
    d(_d), t(_t), a(_a), b(_b), i(_i) {}
  bool operator<(const Event &e) const {
    return d < e.d || (d == e.d && t < e.t);
  }
  void print() { printf("Ev(%d,%d,%d,%d,%d)\n", d, t, a, b, i); }
};

/* global variables */

SegTreeMin<int,MAX_E2> st;
Event es[MAX_K];
bool yns[MAX_Q];

/* subroutines */

/* main */

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);

  int k = 0;
  for (int i = 0; i < m; i++) {
    int d, a, b;
    scanf("%d%d%d", &d, &a, &b);
    a--, b--;
    es[k++] = Event(d, 1, a, b, i);
  }
  for (int i = 0; i < q; i++) {
    int d, a, b;
    scanf("%d%d%d", &d, &a, &b);
    a--, b--;
    es[k++] = Event(d, 0, a, b, i);
  }
  sort(es, es + k);

  st.init(n, INF);
  //st.set_range(0, n, 0);

  for (int i = 0; i < k; i++) {
    Event &ei = es[i];
    //ei.print();

    if (ei.t == 1) {
      st.set_range(ei.a, ei.b, 1);
      //for (int i = 0; i < n; i++) printf("%d", st.get(i)); putchar('\n');
    }
    else {
      if (ei.a >= ei.b) yns[ei.i] = true;
      else {
	int v = st.min_range(ei.a, ei.b);
	//printf("  v=%d\n", v);
	yns[ei.i] = (v > 0);
      }
    }
  }

  for (int i = 0; i < q; i++) {
    if (yns[i]) puts("Yes");
    else puts("No");
  }
  return 0;
}


### 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
/*  -*- coding: utf-8 -*-
 *
 * 2880.cc: Elevator
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_E2 = 1 << 18; // = 262144
const int MAX_M = 100000;
const int MAX_Q = 100000;
const int MAX_K = MAX_M + MAX_Q;
const int INF = 1 << 30;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T nodes[MAX_E2], inf;
  bool ds[MAX_E2];
  SegTreeMin() {}

  void init(int _n, T _inf) {
    n = _n, inf = _inf;
    for (e2 = 1; e2 < n; e2 <<= 1);
    //fill(nodes, nodes + MAX_E2, inf);
  }

  T get(int i) { return nodes[e2 - 1 + i]; }

  void set_range(int r0, int r1, T v, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return;
    if (r0 <= i0 && i1 <= r1) {
      nodes[k] = v;
      ds[k] = true;
      return;
    }

    int k0 = k * 2 + 1, k1 = k0 + 1;
    if (ds[k]) {
      nodes[k0] = nodes[k1] = nodes[k];
      ds[k0] = ds[k1] = true;
      ds[k] = false;
    }

    int im = (i0 + i1) / 2;
    set_range(r0, r1, v, k0, i0, im);
    set_range(r0, r1, v, k1, im, i1);
    nodes[k] = min(nodes[k0], nodes[k1]);
  }
  void set_range(int r0, int r1, T v) { set_range(r0, r1, v, 0, 0, e2); }
  
  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return inf;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int k0 = k * 2 + 1, k1 = k0 + 1;
    if (ds[k]) {
      nodes[k0] = nodes[k1] = nodes[k];
      ds[k0] = ds[k1] = true;
      ds[k] = false;
    }

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k0, i0, im);
    T v1 = min_range(r0, r1, k1, im, i1);

    return min(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

struct Event {
  int d, t, a, b, i;
  Event() {}
  Event(int _d, int _t, int _a, int _b, int _i):
    d(_d), t(_t), a(_a), b(_b), i(_i) {}
  bool operator<(const Event &e) const {
    return d < e.d || (d == e.d && t < e.t);
  }
  void print() { printf("Ev(%d,%d,%d,%d,%d)\n", d, t, a, b, i); }
};

/* global variables */

SegTreeMin<int,MAX_E2> st;
Event es[MAX_K];
bool yns[MAX_Q];

/* subroutines */

/* main */

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);

  int k = 0;
  for (int i = 0; i < m; i++) {
    int d, a, b;
    scanf("%d%d%d", &d, &a, &b);
    a--, b--;
    es[k++] = Event(d, 1, a, b, i);
  }
  for (int i = 0; i < q; i++) {
    int d, a, b;
    scanf("%d%d%d", &d, &a, &b);
    a--, b--;
    es[k++] = Event(d, 0, a, b, i);
  }
  sort(es, es + k);

  st.init(n, INF);
  //st.set_range(0, n, 0);

  for (int i = 0; i < k; i++) {
    Event &ei = es[i];
    //ei.print();

    if (ei.t == 1) {
      st.set_range(ei.a, ei.b, 1);
      //for (int i = 0; i < n; i++) printf("%d", st.get(i)); putchar('\n');
    }
    else {
      if (ei.a >= ei.b) yns[ei.i] = true;
      else {
	int v = st.min_range(ei.a, ei.b);
	//printf("  v=%d\n", v);
	yns[ei.i] = (v > 0);
      }
    }
  }

  for (int i = 0; i < q; i++) {
    if (yns[i]) puts("Yes");
    else puts("No");
  }
  return 0;
}


```