semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
      int n,i,j,count=0,num=0,countf=0;
      scanf("%d",&n);
      int a[20000],b[20000];
      for(i=0;;i++)
      {
      scanf("%d %d",&a[i],&b[i]);
      if(a[i]==0&&b[i]==0)
      break;
      }
      i=0;
      while(i<n)
      {
                      countf=0;
                      count=0;
                      for(j=0;a[j]!=0||b[j]!=0;j++)
                      {
                      if(b[j]==i)
                      count=count+1;
                      if(a[j]==i)
                      countf=countf+1;
                      }
                     if((count==n-1)&&(countf==0))
                    {
                    num=num+1;
                    printf("%d",i);
                    } 
                      
                      i++;
      }
      if(num==0)
      printf("NOT FOUND");
      getchar();
      getchar();
}
int main()
{
    int n,i,j,k=0,x,y;
    int a[10000],b[10000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
       a[i]=0;
       b[i]=0;
    }
     for(;;)
      {
         scanf("%d %d",&x,&y);
         a[x]+=1;
         b[y]+=1;
         if((x==0) && (y==0))
         break;
      }
      for(j=0;j<n;j++)
      {
          if((a[j]==0)&&(b[j]==n-1))
          {
              k=k+1;
              printf("%d",j);
              break;
          }            
      }
    if(j==n)
     printf("NOT FOUND");
}
int main()
{
	int Person[10000] = {0};
	int n;
	cin >> n;
	int i, j;
	while (cin >> i >> j && (i != 0 || j != 0))
	{
		Person[i] = 1;
		Person[j] ++;
	}
	for (i = 0; i < n; i++)
	{
		if (Person[i] == n - 1)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
	int n,t,c[10000]={0},t1,t2;
	scanf("%d",&n);
sd:	
	scanf("%d %d",&t1,&t2);
	if((t1+t2)!=0)
	{
		c[t1]--;
		c[t2]++;
		goto sd;
	}
	for(t=0;t<=n-1;t++)
	{
		if(c[t]==n-1){goto s;}
		else if(t==n-1)
		{
			printf("NOT FOUND\n");
			goto ss;
		}
	}
s:
	printf("%d\n",t);
ss:
	//printf("%d %d %d\n",n,c[0],c[1]);
	return 0;
}
int data[10000][10000] = {0};

int main()
{
	int n;
	cin >> n;
	int x, y;
	while(1)
	{
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		data[x][y] = 1; // x??y?data[x][y] = 1
	}

	//??????????????
	x = 0;
	y = 1;
	while (y < n)
	{
		if (data[x][y] == 1) // x??y???x?????????y???????
		{
			x = y; // ??x
		}
		y ++; // y??
	}

	// ????????x????????????????
	int m;
	for (m = 0; m < n; m ++)
	{
		if (m == x) continue; // ??????????

		// ?????????x??x????????x?????????
		if (! (data[m][x] == 1 && data[x][m] == 0))
		{
			break;
		}
	}
	if (m == n) // ?n????????break?????x??????
		cout << x << endl;
	else // ??????????
		cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
	int n,a[10000][2],i,j,t=0,s,k=0;
	scanf("%d",&n);
    for(i=0;;i++)
	{
	     scanf("%d %d",&a[i][0],&a[i][1]);
		 t++;
		 if((a[i][0]==0)&&(a[i][1]==0))
		 {
			 break;
		 }
	}
	for(i=0;i<n;i++)
	{
		s=0;
		for(j=0;j<t-1;j++)
		{
			if(a[j][0]!=i)
			{
			   if(a[j][1]==i)
				  s++;
			}
			else
				break;
		}
		if(s==n-1)
		{
			k++;
			printf("%d\n",i);
		}
	}
	if(k==0)
	{
		printf("NOT FOUND");
	}
    return 0;
}
main()
{
  int i=0,j,k,n,max=0,sb,a[20000],b[20000],c[10000]={0};
  scanf("%d",&n);
  while(true)
  {
     scanf("%d %d",&a[i],&b[i]);
     if(a[i]==0 && b[i]==0)
       break;
     else
       i++;            
  } 
  for(j=0;j<i;j++)
      c[b[j]]++;  
  for(k=0;k<n;k++)
  {
     if(max<c[k])
       {
         max=c[k];
         sb=k;
       }
  }
  if(max==n-1)
     printf("%d",sb);
  else
     printf("NOT FOUND");
}
void main()
{
	int n,i,j;
	scanf("%d",&n);
	double a[10000]={0};
	do
	{
	scanf("%d %d",&i,&j);
	if(i!=j)
	{a[i]=0.5;
	a[j]=a[j]+i;}
	}while((i>0)||(j>0));
	j=0;
    for(i=0;i<n;i++)
    {
		if (a[i]==(n*(n-1)/2-i))
		{printf("%d\n",i);j=1;}
	}
	if(j==0)
		printf("not found");
}
int main()
{
	int i, j, n, flag = 0, a[10000] = {0}, b[10000] = {0};
	cin >> n;
	while(cin >> i >> j)
	{
		if(i == 0 && j == 0)
		{
			break;
		}
		a[i] = a[i] + 1;
		b[j] = b[j] + 1;
	}
	for(i = 0 ; i < n ; i++)
	{
		if(a[i] == 0 && b[i] >= n - 1)
		{
			cout << i << endl;
			flag = 1;
			break;
		}
	}
	if(flag == 0)
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
void main(){
	int n;
	int i,j;
	int p[10000]={0};
	int sum=0;
	scanf("%d",&n);
	for(;;){
		scanf("%d %d",&i,&j);
		if(i==0&&j==0)
			break;
		else{
			p[i]=-n;
			p[j]+=1;
		}
	}
	for(i=0;i<n;i++){
		if(p[i]==n-1){
			printf("%d\n",i);
			sum=sum+1;
		}
	}
	if(sum==0)
		printf("NOT FOUND\n");
}
main()
{
      int m,n,i,j,k,l;
      int a[10030];
      int b[10030]; 
      for (i=0;i<10020;i++)
      {
          a[i]=0;
          b[i]=0;
          } 
      scanf("%d",&n);
    
      while (1) 
      {
            scanf("%d %d",&i,&j);
            if ((i==0)&&(j==0)) break; 
            a[j]++;
            b[i]++; 
            }
            k=0; 
      for (l=0;l<n;l++)
      if ((a[l]==n-1)&&(b[l]==0)) 
      {
                                printf("%d\n",l);
                                k=1; 
                                } 
                                if (k==0) printf("NOT FOUND");
                             
                                }
int main()
{
	int n,relation[10000]={0},i,ans=-1;
	cin>>n;
	int a , b;
	while(cin>>a>>b)
	{
		if(a==0 && b==0) break;
		relation[a]++;
		relation[b]++;
	}
	for(i=0;i<n;i++)
	{
		if(relation[i]==n-1) ans=i;
	}
	if(ans==-1) cout<<"NOT FOUND"<<endl;
	else cout<<ans<<endl;
	return 0;
}
int map[20000][20000];
int main()
{
	int n, i, j;
	int found = 0;
	cin >> n;
	cin >> i >> j;
	while ((i != 0)||(j != 0))
	{
		map[i][j] = 1;
		cin >> i >> j;
	}
	for (i = 0; i < n; i++)
	{
		int mark = 0;
		for (j = 0; j < n; j++)
		{
			if ((map[i][j] == 1)&&(i != j))
			{
				mark = 1;
				break;
			}
		}
		if (mark == 0)
		{
			int mark2 = 0;
			for (j = 0; j < n; j++)
			{
				if ((j != i)&&(map[j][i] == 1))
					mark2++;
			}
			if (mark2 == n-1)
			{
				found = 1;
				cout << i << endl;
				break;
			}
		}
	}
	if (found == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main(){
	int *a;
	int *b;
	int n;
	int i,j,pd=0;
	int all;
	int k,m;
	int u,v;
	scanf("%d",&n);
	all=n*(n-1);
	a=(int*)malloc(sizeof(int)*n);
	b=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		a[i]=0;
		b[i]=0;
	}
	for(i=0;i<all;i++){
		scanf("%d%d",&k,&m);
		if((k!=0)||(m!=0)){
			a[k]++;
			b[m]++; 
			if((b[m]==n-1)&&(a[m]==0)){
				printf("%d",m);
				pd=1;
			}
		}
		else if ((k==0)&&(m==0)){
			break;
		}
	}
	if(pd==0){
		printf("NOT FOUND");
	}
	free(a);
	free(b);
	return 0;
	}
int main()
{
	int p[10001]={0},q[10001]={0};
	int n,a,b,i;
	cin>>n;
	for(i=0;;i++)
	{
		cin>>a>>b;
		if(a==0 && b==0) break;
		p[b]++;
		q[a]=1;
	}
	for(i=0;i<n;i++)
	{
		if(p[i]==n-1 && q[i]==0)
		{
			cout<<i<<endl;
			break;
		}
	}
	if(i==n) cout<<"NOT FOUND"<<endl;
return 0;
}
int know[10000],bknown[10000];
int main()
{
    int n,i,a,b;

    scanf("%d",&n);
    for(i=0;i<n;i++) know[i]=bknown[i]=0;
    while(scanf("%d%d",&a,&b))
    {
        if(a==b&&b==0) break;
        know[a]++;
        bknown[b]++;
    }
    for(i=0;i<n;i++)
        if(know[i]==0&&bknown[i]==n-1) break;
    if(i<=n) printf("%d\n",i);
    else printf("NOT FOUND\n");
    return 0;
}
main()
{
      int n;
      scanf("%d",&n); 
      int *p;
      p=(int*)calloc(n,sizeof(int));


      int j,k;
      for(;;)
      {
              scanf("%d%d",&j,&k);
              if(j==0&&k==0)
              break;
              *(p+j)=-1;
              if(*(p+k)!=-1)
              *(p+k)=*(p+k)+1;
      }
      
      int count=0;
      for(int i=0;i<n-1;i++)
      {
              if(*(p+i)==n-1)
              {
                             printf("%d",i);
                             count=1;
              }
      }
      if(count==0)
      printf("NOT FOUND");
      free(p);
}
int main()
{
 int n,a[100000][2],i,j,q;   
 int b[100000]={0},c[100000]={0};
 scanf("%d",&n);
 scanf("%d %d",&a[0][0],&a[0][1]);
 
 for(i=1;a[i-1][0]+a[i-1][1]!=0;i++) 
  scanf("%d %d",&a[i][0],&a[i][1]);
 q=i-1;                 
 
 for(j=0;j<n;j++)
 { 
  for(i=0;i<q;i++)
  {
   if(j==a[i][1])
   b[j]++;               
  } 
 }
 
 for(j=0;j<n;j++)
 { 
  for(i=0;i<q;i++)
  {
   if(j==a[i][0])
   {
    c[j]++;
    break;
   }               
  } 
 }
 for(j=0;j<n;j++)
 {
  if(b[j]==n-1&&c[j]==0)
  printf("%d",j);                
 } 
 getchar();
 getchar();
 return 0;
}
int main()
{
 	int n, a[10005] = {0}, x, y; //a???????? 
 	int sum[10005] = {0}, i; //sum???????????? 
 	
 	cin >> n; 	
 	cin >> x >> y;
 	while ( x != 0 || y != 0 )
 	{
  	 	a[x] = 1;
		sum[y]++;
		cin >> x >> y;     
  	}
  	for ( i = 0; i < n; i++ )
  	{
	 	if ( sum[i] == n - 1 && a[i] == 0 )
		{   cout << i << endl; 
			break;
		}	 
    }
    if ( i == n )
       cout << "NOT FOUND" << endl;
 	
 	return 0;
}
int main()
{
	int result=1;
	int n;
	int i;
	cin>>n;
	int m[10000][2];//m[i][0]??m??????m[i][1]????m???
	int a,b;
	for(i=0;i<10000;i++)
	{
		m[i][0]=m[i][1]=0;
	}
	while(cin>>a>>b)
	{
		if(a==0&&b==0)
		{
			break;
		}
		m[a][0]++;
		m[b][1]++;
	}
	for(i=0;i<n;i++)
	{
		if(m[i][0]==0&&m[i][1]==n-1)
		{
			result=0;
			cout<<i<<endl;
		}
	}
	if(result)
	{
		cout<<"NOT FOUND"<<endl;
	}
	return 0;
}
//*************************************************
//***?????????***
//***??????***
//***???2012.12.14***
//*************************************************
int main ()
{
	int n,a[10000],flag_a[10000],x,y,i,flag = 0;  //a[i]????????i;flag_a[i]??i??????
	memset(a,0,sizeof(a));                        //???????0    
	memset(flag_a,0,sizeof(flag_a));
	cin >> n;                                     //????
	cin >> x >> y;
	while(x != 0 || y != 0)
	{
		flag_a[x] = 1;                            //??????????1
		if (flag_a[y] != 1)
		{
			a[y]++;                               //?????????????1
		}
		cin >> x >> y;
	}
	for (i = 0; i < n; i++)                       //???????????????????????
	{
		if (flag_a[i] == 0 && a[i] == n - 1)
		{
			cout << i << endl;
			flag = 1;
		}
	}
	if (flag == 0)                                //??????"NOT FOUND"
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
int main()
{
	int n,p1[10000],p2[10000],k,i,j;
	cin>>n;
	for(k=0;k<n;k++)
		p1[k]=p2[k]=0;
	while(cin>>i>>j)
	{
		if(i==0&&j==0) break;
		p1[i]++;
		p2[j]++;
	}
	for(k=0;k<n;k++)
		if(p2[k]==n-1&&p1[k]==0)
		{
			cout<<k;
			break;
		}
	if(k==n)
	cout<<"NOT FOUND";
	return 0;

}
//******************************
//*?? ??????          **
//*?? ??? 1100016602     **
//*?? 2011?12?14?        **
//****************************** 


int main()
{
    int n , a[100001] , b[100001] , *p , *q , i , j ; //???? a[i]????i??????b[i]??i??????? 
    cin >> n ;                                        //????? 
    memset(a , 0 , sizeof(a)) ;                       //????? 
    memset(b , 0 , sizeof(b)) ; 
    for ( ; ; )                                       //????????i????????1???j?????+1 
    {
        cin >> i >> j ; 
        if ((i == 0) && (j == 0))
            break ; 
        a[j] ++ ; 
        b[i] ++ ; 
    }
    for (p = &(a[0]) , q = &(b[0]) , i = 0 ; i < n ; i ++ ) //???????????????????????0???n - 1????????? 
    {
        if ((*(p + i) == n - 1) && (*(q + i) == 0))
        {
            j = i ;   //?i???? 
            break ; 
        }
    }
    if (j == n)                                             //?j????n???????? 
        cout << "NOT FOUND" << endl ; 
    else                                                    //?????????? 
        cout << j << endl ; 
    return 0 ; 
}
/*
 * shehuimingliu.cpp
 *
 *  Created on: 2010-12-13
 *      Author: ??
 *      ????????
 */
int main()
{
	int i,a[10000]={0},n,a1,a2,flag=0;
	cin >> n;

	while(1)
	{
		cin >> a1 >> a2;
		if(a1==0&&a2==0) break;
		else { a[a1]=-1000; a[a2]++;}
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==n-1) {
			cout << i;
		   flag=1;}
	}
	if(flag==0) cout << "NOT FOUND";
	return 0;
}
main()
{
    int n,i,j,*p,*q;
    scanf("%d",&n);
    p=(int*)calloc(n,sizeof(int));
    q=(int*)calloc(n,sizeof(int));
    for(i=0;i<n;i++)
        *(p+i)=0;
        *(q+i)=0;
    for(;;)
        {   scanf("%d %d",&i,&j);
            if(i==0&&j==0)
                break;
            if(*(p+i)!=1)
                *(p+i)=1;
            *(q+j)=*(q+j)+1;
            }
    //for(i=0;i<n;i++)
       //printf("%d %d\n",*(p+i),*(q+i));
    for(i=0;i<n;i++)
        {   if(*(p+i)==0&&*(q+i)==n-1)
                {   printf("%d",i);
                    break;}
            if(i==n-1)
                printf("NOT FOUND");
                        }
    


    }
int main()
{
	int a[10000][2];
	int n,i;
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	int b,c,f;
	while(scanf("%d %d",&b,&c))
	{
		if(b==0&&c==0)
			break;
		a[b][0]=1;
		a[c][1]++;
	}
	f=0;
	for(i=0;i<n;i++)
	{
		if(a[i][0]==0&&a[i][1]==n-1)
		{
			f=1;
			printf("%d\n",i);
		}
	}
	if(f==0)
		printf("NOT FOUND\n");
}
int main()
{
	int n,i;
	scanf("%d",&n);
	int num1[10000];
	int num2[10000];
	int order[10000];
	int a,b;
	for(i=0;i<n;i++)
	{
	  num1[i]=0;
	  num2[i]=0;
	  order[i]=i;
	}
	while(1)
	{
	  scanf("%d %d",&a,&b);
	  if(a==0&&b==0)
	  {
		break;
	  }
	  num2[a]=num2[a]+1;
	  num1[b]=num1[b]+1;
	}
	for(int k=1;k<n;k++)
	{
	  for(i=0;i<n-k;i++)
	  {
		if(num1[i]>=num1[i+1])
		{
		  int e1=num1[i+1];
		  num1[i+1]=num1[i];
		  num1[i]=e1;
		  int e2=order[i+1];
		  order[i+1]=order[i];
		  order[i]=e2;
		  int f=num2[i+1];
		  num2[i+1]=num2[i];
		  num2[i]=f;
		}
	  }
	}
	int max=num1[n-1];
	int num=1;
	for(i=n-1;max==num1[i];i--)
	{
	  num++;
	}
	if(max!=n-1)
	{
	  printf("NOT FOUND");
	}
	if(max==n-1)
	{
	  for(i=n-1;num1[i]==n-1;i--)
	  {
		if(num==1)
		{
		  if(num2[i]==0)
		  {
		    printf("%d",order[i]);
			break;
		  }
		  if(num2[i]!=0)
		  {
		    printf("NOT FOUND");
		    break;
		  }
		}
		if(num>1)
		{
	      if(num2[i]==0)
		  {
		    printf("%d\n",order[i]);
		  }
		}
		  num--;
	  }
	}
	return 0;
}
//****************???????????************
//****************???????*******************
//****************?????2012?12?12?*********
//****************???1200062701****************


struct c_in
{
	int x;
	int y;
}
sample[5000 * 9999];
struct c_out
{
	int m;
	int time;
}
name[5000 * 9999];
int main()
{
	int n, i, flag = 0; 
	cin >> n;                                         //???n??
	
	for(i = 0; ; i++)
	{
		cin >> sample[i].x >> sample[i].y;
		if((sample[i].x == 0)&&(sample[i].y == 0))
		{
			break;
		}
	}
	for(int j = 0; j < n; j++)                     //???????????
	{
		name[j].m = j;
		name[j].time = 0;
	}
	for(int j = 0; j < i; j++)                     //??????? 0 0 ?????
	{
		(name[sample[j].y].time)++;
	}
	for(int j = 0; j < n; j++)                     
	{
		if(name[j].time == n - 1)
		{
			cout << name[j].m;
			flag += 1;
		}
	}
	if(flag == 0)
	{
		cout << "NOT FOUND";
	}
	return 0;
}
int main()
{
	int n,i,j;
	int know[10000]={0};
	cin>>n;
	for (i=0;i<n;i++)
		know[i]=0;
	while (cin>>i>>j)
	{
		if (i==j&&i==0)
			break;
		know[i]=-1;
		if (know[j]!=-1)
		{
			know[j]++;
			if (know[j]==n-1)
				cout<<j<<endl;
		}
	}
	return 0;
}
int main()
{
    int i,n,j,k,t=0;
    scanf("%d",&n);
    int*p=(int*)malloc(n*sizeof(int));
    int*q=(int*)malloc(n*sizeof(int));
    for(i=0;i<=n;i++)
    p[i]=q[i]=0;
    for(k=0;;k++)
    {
                 scanf("%d %d",&i,&j);
                 if((i==0)&&(j==0))break;
                 p[i]=p[i]+1;
                 q[j]=q[j]+1;}
    for(i=0;i<=n;i++)
    {
                     if((p[i]==0)&&(q[i]==n-1))
                     {
                                             printf("%d",i);
                                             t=t+1;
                     }
    }
    if(t==0)
    printf("NOT FOUND"); 
}
int main()
{
	int a[100000] = {0}, i, b, c, n, d[100000] = {0}, f = 0, *p = a, *q = d;
	cin >> n;
	while(cin >> b >> c)
	{
		if ((b == 0) && (c == 0))
			break;
		(*(p + b))++;
		(*(q + c))++;
	}
	for (i = 0; i <= n-1; i++)
	{
		if ((a[i] == 0) && (d[i] == n - 1))
		{
			f = 1;
			cout << i;
		}
	}
	if (f == 0)
		cout << "NOT FOUND" ;
	return 0;
}
main()
{
      int i,j;
      int a,b,c;
      int n;
      
      scanf("%d",&n);
      int*p=(int*)malloc(n*sizeof(int));
      for(i=0;i<n;i++)
      p[i]=0;
      c=0;
      j=0;
      
      
      for(;;)
      {
             scanf("%d %d",&a,&b);
             if(a==0&&b==0) break;
             else
             {
                 if(b==0)
                 j=j+1;
                 else
                 {
                     i=b;
                     p[i]=p[i]+i;
                 }
             }
      }
      
      
      if(j==n-1)
      {
                printf("0");
                c=1;
      }
      else
      {
          for(i=1;i<n;i++)
          {
                          if(p[i]/i==(n-1))
                          printf("%d",i);
                          c=c+1;
          }
      }
      if(c=0)
      printf("NOT FOUND");
      getchar();
      getchar();
}
int main(int argc, char* argv[])
{
	int i,j,mingren = 0;
	int count;
	int *person = NULL;
	int num = 0;
	int temp1,temp2;

	scanf("%d", &num);
	count = num;

	int **relation=(int **)malloc(num*sizeof(int *));
	for(i = 0; i < num; i ++)
	{
		relation[i]=(int *)malloc(num * sizeof(int));
	}
	//?????,?????????
	do 
	{
		scanf("%d %d", &temp1, &temp2);
		relation[temp1][temp2] = 1;
	} while (temp2 != 0 || temp1 != 0);
	//////////////////////////////////////////////////////////
	temp1 = 0;
	temp2 = 1;
	for (i = 0; i < num-2; i ++)
	{
		if(relation[temp1][temp2] == 1)
		{
			temp1 = num-1-i;
		}
		else
		{
			temp2 = num-1-i;
		}
	}
	if(relation[temp1][temp2] == 1)
	{
		mingren = temp2;
	}
	else
	{
		mingren = temp1;
	}
	
	for (i = 0; i < num; i ++)//?????????
	{
		if (i != mingren)
		{
			if(relation[i][mingren] == 0 || relation[mingren][i] == 1)
			{
				mingren = -1;
				break;
			}
		}
	}

	///////////////////////////////////////////////////////////

	if (mingren == -1)
	{
		printf("NOT FOUND\n");
	}
	else
	{
		printf("%d\n", mingren);
	}

	for(i = 0; i < num; i ++)
	{
		free(relation[i]);
	}
	free(relation);

	return 0;
}
//*******************************************************
//*12.7??  ??????                               *
//*?????  ?? 1100012844                          *
//*???2011?12?10?                                 *
//*******************************************************
int main()
{
	int a[10000][2], n, i, j, k, flag = 1;
	int (*p)[2] = NULL;
	memset(a, 0, sizeof(a));
	p = a;
	cin >> n;
	cin >> i >> j;
	while (i != 0 || j != 0)
	{
		*(*(p + i)) += 1;
		*(*(p + j) + 1) += 1;
		cin >> i >> j;
	}
	for (k = 0; k < n; k++)
		if (a[k][0] == 0 && a[k][1] == n - 1)
		{
			cout << k << endl;
			flag = 0;
		}
	if (flag)
		cout << "NOT FOUND" << endl;
	return 0;
}
main()
{
   int n,i,j,sum=0,a[100000],b[100000],c[10000],d[10000];
   scanf("%d",&n);
   for(i=0;;i++)
      {
       scanf("%d %d",&a[i],&b[i]);
       if (a[i]==0&&b[i]==0)
          break;
      }   
   for(j=0;j<=n-1;j++)
      {
         c[j]=0;
         d[j]=0;
      }   
   for(j=0;j<=i-1;j++)
      {
         c[b[j]]++;
         d[a[j]]++;
      }
   for(i=0;i<=n-1;i++)
      {
         if(c[i]==n-1&&d[i]==0)
           {
            printf("%d",i);
            sum++;
           }
      }
   if (sum==0)
     printf("NOT FOUND");
}
main()
{
      int n,i;
      scanf("%d",&n);
      int *num=(int*)malloc(n*sizeof(int));
      for(i=0;i<n;i++)
      {
              *(num+i)=0;
      }
      for(;;)
      {
             int a,b;
             scanf("%d %d",&a,&b);
             if(a==0&&b==0) break;
             num[a]--;
             num[b]++;
      }
      for(i=0;i<n;i++)
      {
              if (num[i]==n-1)
              {
                              printf("%d",i);
                              break;
              }
      }
      if(i==n) printf("NOT FOUND");
     
}
int main ()
{
	int n, i, g = 0;
	cin >> n;
	int a1[1000000], a2[1000000], num[1000000] = {0};
	for (i = 0; i <= n * (n - 1); i++)
	{
		cin >> a1[i] >> a2[i];
		if (a1[i] == 0 && a2[i] == 0) break;
		num[a2[i]]++;
	}
	for (i = 0; i < n; i++)
	{
		if (num[i] == n - 1)
		{
			g = 1;
			cout << i;
		}	
	}
	if (g == 0) cout << "NOT FOUND";
	return 0;
}
int main()
{
	int a[100000][2], b[100000], i, n;
	cin >> n;
	memset(b, 0, sizeof(b));
	for(i = 0; ; i++)
	{
		cin >> a[i][0] >> a[i][1];
		if(a[i][0] == 0 && a[i][1] == 0)
			break;
		if(a[i][0] != a[i][1])
			b[a[i][0]] = 1;
	}
	for(i = 0; i < n; i++)
	{
		if(b[i] == 0)
		{
			cout << i << endl;
			break;
		}
	}
	if(i == n)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
	int n,i,j;
	int flag[10000]={0},num[10000]={0};
	cin>>n;
	while(cin>>i>>j)
	{
		if(i == 0 && j == 0)
			break;
		flag[i] = 1;
		num[j] ++;
	}

	for(i = 0;i < n; i++)
	{
		if(flag[i] == 0)
		{
			if(num[i] == n - 1)
				cout<<i<<endl;
			else
				cout<<"NOT FOUND"<<endl;
			break;
		}

	}
	if(i == n)
		cout<<"NOT FOUND"<<endl;

    return 0;
}
int main()
{
	struct people
	{
		int x,y;
	}
	a[60000];
	int n,i=-1;
	int count=-1;
	int j,k;
	int elite=0;
	int num=0;
	scanf("%d",&n);
	do
	{
		i++;
		count++;
		scanf("%d %d",&a[i].x,&a[i].y);
	}
	while (a[i].x!=0 || a[i].y!=0);
	for (i=0;i<count;i++)
	{
		for (j=0;j<count;j++)
		{
			if (a[j].y==a[i].y)
			{
				num++;
			}
		}
		if (num==n-1)
		{
			for (k=0;k<count;k++)
			{
				if (a[k].x!=a[i].y)
				{
					elite++;
				}
			}
			if (elite==count)
			{
				printf("%d\n",a[i].y);
				return 0;
			}
			else
			{
				elite=0;
				num=0;
			}
		}
		else
		{
			elite=0;
			num=0;
		}
	}
	printf("NOT FOUND\n");
	return 0;
}
int main()
{
    int n,i;
    int a[100000],b[100000];
    scanf("%d",&n);
    for(i=0;;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==0&&b[i]==0)
        {
            break;
        }
    }
    int count=0;
    for(int l=0;l<n;l++)
    {
        count=count+l;
    }
    for(int j=0;j<n;j++)
    {
        int count1=0,count2=0;
        for(int k=0;k<i;k++)
        {
            if(a[k]==j)
            {
                count1++;
            }
            if(b[k]==j)
            {
                count2=count2+a[k];
            }
        }
        if(count1==0&&count2==count-j)
        {
            printf("%d\n",j);
        }
    }
    return 0;
}
int main()
	{
		int n,sz[1000000][2],i,k,s,p=0,t,m=0,f;
		scanf("%d",&n);
		sz[0][0]=1;
		for(i=0;1;i++)
		{  
			{
				scanf("%d%d",&sz[i][0],&sz[i][1]);
				p++;
				if((sz[i][0]==0)&&(sz[i][1]==0))
				{
					break;
				}
			}
		}

		for(k=0;k<n;k++)
		{	
			s=0;
			t=0;
			f=0;
			
			for(i=0;i<p-1;i++)
				{
					if(sz[i][1]==k)
					{
						s++;
					}
					if(sz[i][0]==k)
					{
						f=1;
						break;
					}
				
				}
			if((s==n-1)&&(f==0))
			{
				printf("%d",k);
				break;
			}
			else
			{
				m++;
			}
		}
		if(m==n)
		{
			printf("NOT FOUND");
		}
		return 0;
	}
main()
{
      int n,i,a,b;
      int*p;
      int*q;
      scanf("%d",&n);
      p=(int*)(malloc(n*sizeof(int)));
      q=(int*)(malloc(n*sizeof(int)));
      for(i=0;i<n;i++)
      {
           *p=0;
           *q=0;
           p+=1;q+=1;
      }
      p=p-n;q=q-n;
      for(;;)
      {
             scanf("%d %d",&a,&b);
             if((a==0)&&(b==0))
             break;
             p[a]+=1;q[b]+=1;
      }
      for(i=0;i<n;i++)
      {
             if((p[i]==0)&&(q[i]==n-1))
             {
                 printf("%d",i);
                 break;
             }
      }
      if(i==n)
      printf("NOT FOUND");
      
}
main()
{
      int count=0,non=0;
      int n,l;
      scanf("%d",&n);
      int a[1000000]={0};
      int b[1000000]={0};
      int c[1000000]={0};

      for(int i=0;;i++)
      {
              scanf("%d %d",&a[i],&c[i]);
              l=i;
              if(a[i]==0 && c[i]==0)
              break;
      }
      for(int i=0;i<l;i++)
      b[c[i]]++;
      for(int i=0;i<l;i++)
      {
              if(b[i]==n-1)
              {
                           for(int j=0;j<l;j++)
                           if(a[j]==i)
                           count=1;
              }
              if(b[i]==n-1 && count==0)
              {
              printf("%d",i);
              non=1;
              break;
              }
      }
      if(non==0)
      printf("NOT FOUND");
}
int main()
{
  int n,a,b;    
  struct p
  {
      int k;
      int count;  
  }p[10000];
  cin>>n>>a>>b;
  for(int i=0;i<n;i++)
	  p[i].count=0;
  while(!(a==0 && b==0))
  {
      p[b].count++;
      cin>>a>>b;
  }
  for(int i=0;i<n;i++)
	  if(p[i].count == n-1)
	  {    
		  cout<<i;
          return 0;
      }
  cout<<"NOT FOUND";
}