并查集入门
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<cstdlib>
#include<vector>
using namespace std;
#define cl(a,b) memset(a,b,sizeof(a))
#define LL long long
#define pb push_back
#define gcd __gcd
#define For(i,j,k) for(int i=(j);i<k;i++)
#define lowbit(i) (i&(-i))
#define _(x) printf("%d\n",x)
const int maxn = 2e6+10;
const int inf = 1 << 28;
int f[maxn];
void init(int n){
for(int i=0;i<=n;i++)f[i]=i;
}
int find(int x){
if(x==f[x])return x;
return f[x]=find(f[x]);
}
void merge(int x,int y){
x = find(x);
y = find(y);
if(x==y)return ;
f[x]=y;
}
int id = 1;
map<string,int> mp;
int getid(string s){
if(!mp.count(s))return mp[s]=id++;
return mp[s];
}
int main(){
int n;
scanf("%d",&n);init(n);
for(int i=0;i<n;i++){
int type; string a,b;
cin>>type>>a>>b;
int ida = getid(a);
int idb = getid(b);
if(type==0)merge(ida,idb);
else {
printf("%s\n",find(ida)==find(idb)?"yes":"no");
}
}
return 0;
}