#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M,Q;

int ans[111111];
signed main(){
    cin>>N>>M>>Q;

    vector<tuple<int,int,int,int>>qs;
    rep(i,M){
        int d,a,b;
        cin>>d>>a>>b;
        d=d*2+1;
        a--;b--;
        qs.pb(make_tuple(d,a,b,-114514));
    }
    rep(i,Q){
        int e,s,t;
        cin>>e>>s>>t;
        s--;t--;
        e=e*2;
        qs.pb(make_tuple(e,s,t,i));
    }

    sort(all(qs));
    set<int>latte;
    rep(i,N-1)latte.insert(i);
    UnionFindTree uf(N);
    rep(i,qs.size()){
        int hoge,s,t,k;
        tie(hoge,s,t,k)=qs[i];
        if(hoge&1){
            while(true){
                auto it=latte.lower_bound(s);
                if(it==latte.end())break;
                if(*it>=t)break;
                uf.unite(*it,*it+1);
                latte.erase(it);
            }
        }
        else{
            if(s>=t)ans[k]=true;
            else{
                ans[k]=uf.areSame(s,t);
            }
        }
    }

    rep(i,Q){
        if(ans[i])puts("Yes");
        else puts("No");
    }
    return 0;
}


### Prompt

In cpp, your task is to solve 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
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M,Q;

int ans[111111];
signed main(){
    cin>>N>>M>>Q;

    vector<tuple<int,int,int,int>>qs;
    rep(i,M){
        int d,a,b;
        cin>>d>>a>>b;
        d=d*2+1;
        a--;b--;
        qs.pb(make_tuple(d,a,b,-114514));
    }
    rep(i,Q){
        int e,s,t;
        cin>>e>>s>>t;
        s--;t--;
        e=e*2;
        qs.pb(make_tuple(e,s,t,i));
    }

    sort(all(qs));
    set<int>latte;
    rep(i,N-1)latte.insert(i);
    UnionFindTree uf(N);
    rep(i,qs.size()){
        int hoge,s,t,k;
        tie(hoge,s,t,k)=qs[i];
        if(hoge&1){
            while(true){
                auto it=latte.lower_bound(s);
                if(it==latte.end())break;
                if(*it>=t)break;
                uf.unite(*it,*it+1);
                latte.erase(it);
            }
        }
        else{
            if(s>=t)ans[k]=true;
            else{
                ans[k]=uf.areSame(s,t);
            }
        }
    }

    rep(i,Q){
        if(ans[i])puts("Yes");
        else puts("No");
    }
    return 0;
}


```