1 #include<stdio.h>
2 #include<string.h>
3 struct node{
4 char win[20],lost[20];
5 int score;
6 }game[1000];
7 int main()
8 {
9 int i,j,n,flag;
10 while(scanf("%d",&n),n)
11 {
12 memset(game,0,sizeof(game));
13 for(i=0;i<n;++i){
14 scanf("%s%s",game[i].win,game[i].lost);
15 game[i].score=1;
16 }
17 for(i=0;i<n;++i)
18 for(j=0;j<n;++j)
19 if(!strcmp(game[i].lost,game[j].win))
20 game[j].score=0;
21 for(flag=0;flag<n;++flag)
22 if(game[flag].score) break;
23 if(flag==n){
24 puts("No");
25 continue;
26 }else{
27 for(i=flag+1;i<n;++i)
28 if(game[i].score&&strcmp(game[i].win,game[flag].win)) break;
29 if(i==n) puts("Yes");
30 else puts("No");
31 }
32 }
33 return 0;
34 }