Problem: There are n rabbits, one in each of the huts numbered 0 through n − 1.

At one point, information came to the rabbits that a secret organization would be constructing an underground passage. The underground passage would allow the rabbits to visit other rabbits' huts. I'm happy.

The passages can go in both directions, and the passages do not intersect. Due to various circumstances, the passage once constructed may be destroyed. The construction and destruction of the passages are carried out one by one, and each construction It is assumed that the rabbit stays in his hut.

Rabbits want to know in advance if one rabbit and one rabbit can play at some stage of construction. Rabbits are good friends, so they are free to go through other rabbit huts when they go out to play. Rabbits who like programming tried to solve a similar problem in the past, thinking that it would be easy, but they couldn't write an efficient program. Solve this problem instead of the rabbit.



Input

The first line of input is given n and k separated by spaces. 2 ≤ n ≤ 40 000, 1 ≤ k ≤ 40 000

In the following k lines, construction information and questions are combined and given in chronological order.

* “1 u v” — A passage connecting huts u and v is constructed. Appears only when there is no passage connecting huts u and v.
* “2 u v” — The passage connecting huts u and v is destroyed. Appears only when there is a passage connecting huts u and v.
* “3 u v” — Determine if the rabbits in the hut u and v can be played.



0 ≤ u <v <n

Output

For each question that appears in the input, output "YES" if you can play, or "NO" if not.

Example

Input

4 10
1 0 1
1 0 2
3 1 2
2 0 1
1 2 3
3 0 1
1 0 1
2 0 2
1 1 3
3 0 2


Output

YES
NO
YES

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 40005;

#define getchar getchar_unlocked
#define putchar putchar_unlocked

inline int in() {
    int n, c;
    while ((c = getchar()) < '0') if (c == EOF) return -1;
    n = c - '0';
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}

map<P,int> mp;

class UF_pop {
public:
    vector<int> par,nrank; vector<vector<int> > hist;
    int sz;
    UF_pop(int node_size){
        sz = node_size;
        par = nrank = vector<int>(sz,0);
        rep(i,sz){
            par[i] = i;
        }
    }
    void reinit(){
        rep(i,sz){
            nrank[i] = 0; par[i] = i;
        }
    }
    int find(int x){
        return (par[x] == x)?(x):find(par[x]);
    }
    void pop(){
        if(len(hist)) {
            auto& a = hist.back();
            par[a[0]] = a[0], nrank[a[0]] = a[1], par[a[2]] = a[2];
            hist.pop_back();
        }
    }
    void unite(int x,int y) {
        x = find(x); y = find(y);
        hist.pb({x,nrank[x],y});
        if(x == y) return;
        if(nrank[x] < nrank[y]){
            par[x] = y;
        }else{
            nrank[x] += (nrank[x] == nrank[y]);
            par[y] = x;
        }
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

vvi vec;

void dfs(int l, int r, UF_pop& uf, vi& vid, vi& qid, vvi& que,vi& res) {
    vi lvid,rvid;
    int num=0;
    int mid = (l+r) / 2;
    int st = lower_bound(all(qid),l) - qid.begin();
    int ed = lower_bound(all(qid),r) - qid.begin();
    if(ed <= st){
        return;
    }
    if(vid.empty()){
        srep(i,st,ed){
            if(uf.same(que[i][0],que[i][1])){
                res[i] = 1;
            }
        }
        return;
    }
    each(i,vid){
        vi& v = vec[i];
        if(v[2] <= l && r <= v[3]) {
            uf.unite(v[0],v[1]);
            ++num;
        }else{
            if(v[2] < mid){
                lvid.pb(i);
            }
            if(v[3] > mid){
                rvid.pb(i);
            }
        }
    }
    dfs(l,mid,uf,lvid,qid,que,res);
    dfs(mid,r,uf,rvid,qid,que,res);
    while(num){
        uf.pop();
        --num;
    }
}

int main(){
    int n = in(), q = in();
    vi vid,qid;
    vvi que;
    rep(i,q){
        int x = in(), y = in(), z = in();
        if(x == 1){
            mp[{y,z}] = i;
        }else if(x == 2){
            vec.pb({y,z,mp[{y,z}],i});
            mp.erase({y,z});
        }else{
            qid.pb(i);
            que.pb({y,z});
        }
    }
    each(it,mp){
        vec.pb({(it.fi).fi,(it.fi).se,it.se,q});
    }
    vid.resize(len(vec));
    iota(all(vid),0);
    UF_pop uf(n);
    vi res(len(que),0);
    dfs(0,q,uf,vid,qid,que,res);
    rep(i,len(res)){
        if(res[i]){
            putchar('Y'), putchar('E'), putchar('S'), putchar('\n');
        }else{
            putchar('N'), putchar('O'), putchar('\n');
        }
    }
    return 0;
}