include<stdio.h>
include
include
include
include<string.h>
include
include
using namespace std;
///找出入度为0的有且只有一个即可以产生冠军,不用拓扑排序
int du[2005];
bool panDuan(int n)///判断所有点的入度为0的个数
{
int sum=0;
for(int i=1; i<=n; i++)
if(du[i]0)
{
sum++;
if(sum>=2)return false;
}
if(sum1)return true;
else return false;
}
int main()
{
int n;
while(scanf("%d",&n),n)
{
string a,b;
map<string,int >m;///将人名映射成一个编号
memset(du,0,sizeof(du));
int k=0;
for(int i=1; i<=n; i++)
{
cin>>a >>b;
if(m[a]0)m[a]=++k;///没有赋值之前初始值是0
if(m[b]0)m[b]=++k;
du[m[b]]++;///入度加一
}
if(panDuan(k))printf("Yes
");
else printf("No
");
}
return 0;
}