#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, a, b;
long long N=1e9+7;
map <long long, int> f;
int main(){
scanf("%d%d", &n, &m);
while(m--){
scanf("%d%d%d", &k, &a, &b);
if(k == 3){
if(f[a*N+b] && f[b*N+a]) printf("Yes\n");
else printf("No\n");
}//(a, b) => a*N+b
else f[a*N+b] = k == 1;
}
return 0;
}