1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int compair(char a[],char b[]); 6 int n,i,j,t,frist; 7 struct 8 { 9 char a[100]; 10 char b[100]; 11 } grade[1000]; 12 while(~scanf("%d",&n)&&n) 13 { 14 memset(grade,0,sizeof grade); 15 for(i=0; i<n; ++i) 16 scanf("%s%s",grade[i].a,grade[i].b); 17 for(i=t=0; i<n; ++i) 18 { 19 for(j=0; j<n; ++j) 20 if(compair(grade[i].a,grade[j].b)) 21 break; 22 if(j==n) 23 if(t) 24 { 25 if(!compair(grade[frist].a,grade[i].a)) 26 ++t; 27 } 28 else 29 { 30 frist=i; 31 ++t; 32 } 33 //printf("t=%d ",t); 34 if(t>1) 35 { 36 printf("No "); 37 break; 38 } 39 } 40 if(t==1) 41 printf("Yes "); 42 else if(t<1) 43 printf("No "); 44 } 45 } 46 47 int compair(char a[],char b[]) 48 { 49 int i; 50 for(i=0; a[i]!='