public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int index = Integer.parseInt(scanner.nextLine());
HashMap<String, String> map = new HashMap<String, String>();
for(int i=0; i<index; i++){
String temp = scanner.nextLine();
int mark = Integer.parseInt(temp.split(" ")[0]);
String people1 = temp.split(" ")[1];
String people2 = temp.split(" ")[2];
if(mark == 0) Week14.insert(people1, people2, map);
if(mark == 1){
//如果想这样检查的话,要返回null的字符串,而不是null !!!!!!
// if(!Week14.find(people1, map).equals("null") && !Week14.find(people2, map).equals("null")){
// while( !people1.equals(Week14.find(people1, map)) ){
// people1 = Week14.find(people1, map);
// }
// while( !people2.equals(Week14.find(people2, map)) ){
// people2 = Week14.find(people2, map);
// }
// if(people1.equals(people2)) System.out.println("yes");
// else System.out.println("no");
// }
// else{
// System.out.println("no");
// }
if(!map.containsKey(people1) || !map.containsKey(people2)){
System.out.println("no");
}
else{
while( !people1.equals(Week14.find(people1, map)) ){
people1 = Week14.find(people1, map);
}
while( !people2.equals(Week14.find(people2, map)) ){
people2 = Week14.find(people2, map);
}
if(people1.equals(people2)) System.out.println("yes");
else System.out.println("no");
}
}
}
}
public static void insert(String people1, String people2, HashMap<String, String> map){
if(map.containsKey(people1)){
if(map.containsKey(people2)){
if(map.get(people1).equals(people2)) ; //相同情况,换顺序
else{
while( !people1.equals(Week14.find(people1, map)) ){
people1 = Week14.find(people1, map);
}
while( !people2.equals(Week14.find(people2, map)) ){
people2 = Week14.find(people2, map);
}
map.replace(people2, people1);
}
}
else map.put(people2, people1); //后指前
}
else{
if(map.containsKey(people2)) map.put(people1, people2); //前指后
else{
map.put(people1, people1); //设置前面为终点
map.put(people2, people1); //后指前
}
}
}
public static String find(String people1, HashMap<String, String> map){
if(map.containsKey(people1)) return map.get(people1);
else return "null";
}
}