#include<bits/stdc++.h>

using namespace std;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
   // if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  map< int, vector< tuple< int, int, int > > > mp;

  for(int i = 0; i < M; i++) {
    int d, a, b;
    cin >> d >> a >> b;
    mp[d].emplace_back(1333333, a, b);
  }
  for(int i = 0; i < Q; i++) {
    int e, s, t;
    cin >> e >> s >> t;
    mp[e].emplace_back(i, s, t);
  }
  set< int > st;
  for(int i = 1; i <= N; i++) {
    st.emplace(i);
  }
  UnionFind uf(N + 1);
  vector< int > ans(Q);
  for(auto &v : mp) {
    sort(begin(v.second), end(v.second));
    for(auto &x : v.second) {
      int a, b, c;
      tie(c, a, b) = x;
      if(c == 1333333) {
        auto l = st.lower_bound(uf.find(a));
        while(uf.find(a) != uf.find(b)) {
          uf.unite(uf.find(a), *l);
          l = st.erase(l);
        }
        st.emplace(uf.find(a));
      } else {
        ans[c] = a > b || uf.find(a) == uf.find(b);
      }
    }
  }
  for(auto& x : ans) puts(x ? "Yes" : "No");
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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<bits/stdc++.h>

using namespace std;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
   // if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  map< int, vector< tuple< int, int, int > > > mp;

  for(int i = 0; i < M; i++) {
    int d, a, b;
    cin >> d >> a >> b;
    mp[d].emplace_back(1333333, a, b);
  }
  for(int i = 0; i < Q; i++) {
    int e, s, t;
    cin >> e >> s >> t;
    mp[e].emplace_back(i, s, t);
  }
  set< int > st;
  for(int i = 1; i <= N; i++) {
    st.emplace(i);
  }
  UnionFind uf(N + 1);
  vector< int > ans(Q);
  for(auto &v : mp) {
    sort(begin(v.second), end(v.second));
    for(auto &x : v.second) {
      int a, b, c;
      tie(c, a, b) = x;
      if(c == 1333333) {
        auto l = st.lower_bound(uf.find(a));
        while(uf.find(a) != uf.find(b)) {
          uf.unite(uf.find(a), *l);
          l = st.erase(l);
        }
        st.emplace(uf.find(a));
      } else {
        ans[c] = a > b || uf.find(a) == uf.find(b);
      }
    }
  }
  for(auto& x : ans) puts(x ? "Yes" : "No");
}

```