#include<bits/stdc++.h>
using namespace std;
int pre[1000005];
int find(int x) //路径压缩 1
{
int r=x;
while(pre[r]!=r)
{
r=pre[r];
}
/*int i=x,j;
while(i!=r)
{
j=pre[i];
pre[i]=r;
i=j;
}*/
return r;
}
void join(int x,int y)
{
x=find(x);y=find(y);
if(x!=y)pre[x]=y;
}
void ask(int x,int y)
{
printf("%s\n",find(x)==find(y)?"Yes":"No");
}
int main(void){
pre[1]=1;
pre[2]=3;
pre[3]=2;
pre4[4]=1;
pre[5]=6;
/*join(1,2);
join(2,3);
join(4,1);
join(5,6);*/
ask(1,3);
ask(4,5);
return 0;
}