semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int a[10000]={0},b[10000]={0},i,j,k,p=0,n;
	scanf("%d",&n);
	while(1)
	{
		
		scanf("%d %d",&i,&j);
		if(i==0&&j==0)break;
		else
		{
		a[i]++;
		b[j]++;
		}

	}
	for(k=0;k<n;k++)
	{
		if(a[k]==0&&b[k]==n-1)
		{printf("%d",k);p++;break;}

	}
	if(p==0)printf("NOT FOUND");
	return 0;

}
main()
{
 int i,a,b,n,flag=0,c[101000],d[101000];
 scanf("%d",&n);
 while (scanf("%d%d",&a,&b)==2)
 {
   if (a==0&&b==0)
     break;
   c[b]++;
   d[a]++;     
 }
 for (i=0;i<=n-1;i++)
 if (c[i]==n-1&&d[i]==0)
  {
    printf("%d",i);
    flag=1;                        
  }
 if (flag==0) 
   printf("NOT FOUND\n");
   getchar();
   getchar();
   return 0;    
}
//****************************************
//*??:  ????        ** 
//*??: ???      		    **
//*???2011  12 09              **
//****************************************
int main()
{
	int a, b;           //a,b?????????? 
	int c[2][10001] = {0};   //?????????????????????????? 
	int n;
	int k = 0;
	int *p;             //???? 
	int flag = 0 ;         //??????????????? 
	cin >> n;
	while(1)
	{
		cin >> a >> b; 
		if(a == 0 && b == 0)    break;    //?????? 
		else
		{
			c[0][a]++;      
			c[1][b]++;	        //?? 
		}
	}	
	for(p = c[0]; p < c[0] + n; p++ , k++)         //k????????????????? 
	{ 
		if(*p == 0 && *(p + 10001) == n - 1)	           //?????? 
		{
			cout << k << endl;
			flag = 1;     //?????1 
		}
	}
	if(flag == 0)
	cout << "NOT FOUND" << endl;
}
/*
 * FamousPerson.cpp
 *
 *  Created on: 2013-12-13
 *      Author: KEVIN
 */


int main()
{
	int n;
	cin>>n;
	struct{int knows,known;} person[n];
	memset(person,0,sizeof(person));
	while(1)
	{
		int i,j;
		cin>>i>>j;
		if(i==j)break;
		person[i].knows++;
		person[j].known++;
	}
	for(int i=0;i<=n-1;++i)
	{
		if(person[i].known==n-1 && person[i].knows<n-1)
		{
			cout<<i;
			break;
		}
		else
		{
			if(i==n-1)cout<<"NOT FOUND";
		}
	}
	return 0;
}
//****************************
//*??????**
//*???????**
//*???2012.12.15**
//****************************
int main()
{
	int n, i, k, p, q;
	struct people
	{
		int a;
		int b;
	}peo[10000] = {0};    //a???????????  b?????????
	cin >> n;
	while (1)
	{
		cin >> p >> q;
		if (p == 0 && q == 0)
			break;
		peo[p].a++;
		peo[q].b++;
	}
	k = 0;
	for (i = 0; i < n; i++)
	{
		if (peo[i].a == 0 && peo[i].b == n - 1)
		{
			cout << i << endl;
			k = 1;
		}
	}
	if (k == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main ()
{
	int n,a,b,g=0,i;
	int c[100000]={0},d[10000]={0};
	int *p=c,*q=d;
	cin>>n;
	for(;;)
	{
		cin>>a>>b;
		if(a==0&&b==0)
			break;
		else
		{
			c[b]++;
			d[a]=-1;
		}
	}
	for(i=0;i<n;i++)
		if(c[i]==n-1&&d[i]==0)
		{
			cout<<i;
			g=1;
			break;
		}
	if(g==0)
		cout<<"NOT FOUND"<<endl;
	return 0;
}
int main(){
	int n,x,y,i;         //?????n?x?y????i?j???i??j???0?i,j<n?i?????
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)     //a[n]?????????????0
		a[i]=0;
	while(true){         //???
		cin>>x>>y;
		if(x==0&&y==0) break;     //?????0????
		a[y]=a[y]+x;              //????????
	}
	for(i=0;i<n;i++)     //??a[n]
		if(a[i]==n*(n-1)/2-i){    //??????????
			cout<<i;
			return 0;
		}
	cout<<"NOT FIUND";
	return 0;
}
/*
 * shehuimingliu.cpp
 *
 *  Created on: 2011-12-21
 *      Author: Administrator
 */
int main()
{
	int n,a,b,i,count[2][100000]={0, 0},flag=0,*p=*count;
	cin>>n;
	do
	{
		cin>>a>>b;
		if(a!=0||b!=0)
		{
			*(p+a)+=1;
			*(p+100000*1+b)+=1;
		}
	}
	while(a!=0||b!=0);
	for(i=0;i<n;i++)
	{
		if(*(p+i)==0&&*(p+100000*1+i)==n-1)
		{
			cout<<i<<endl;
			flag=1;
		}
	}
	if(flag==0)
		cout<<"NOT FOUND"<<endl;
	return 0;
}
/**
* @author ??
* @date 2010-12-8
* @description
* ??????:?????? 
*/

int main()
{
	int n, a[10000]= {0}, b[10000] = {0}, x, y, flag = 0;
	cin >> n >> x >> y;
	while(x || y)
	{
		a[x]++;
		b[y]++;
		cin >> x >> y;
	}
	for (int i = 0; i < n; i++)
	{
		if (!a[i] && (b[i] == n - 1))
		{
			cout << i << endl;
			flag = 1;
		}
		if (flag)
			break;
	}
	if (!flag)
		cout << "NOT FOUND" << endl;

	return 0;
}
/*
??????????
??????
?????2011.12.7
*/
void print(int*, int*, int);
int main()
{
	int i, j, n, a[10000] = {0}, b[10000] = {0}, *p, *q;
	cin >> n;
	while(cin >> i >> j)
	{
		if(i == 0 && j == 0)
		{
			break;
		}
		a[i] = a[i] + 1;
		b[j] = b[j] + 1;
	}
	p = a;
	q = b;
	print(p, q, n);
	return 0;
}

void print(int a[], int b[], int n)
{
	int i, flag = 0;
	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;
}
int main()
{
	int n;
	int *exclusion;
	int *refCount;
	int a,b;
	int i;
	int found;
	scanf("%d",&n);
	exclusion=(int*)malloc(sizeof(int)*n);
	refCount=(int*)malloc(sizeof(int)*n);
	memset(exclusion,0,sizeof(int)*n);
	memset(refCount,0,sizeof(int)*n);
	
	while(1)
	{
		scanf("%d %d",&a,&b);
		if (a==0 && b==0) break;
		exclusion[a]=1;
		refCount[b]++;
	}	
	
	found=0;
	for (i=0;i<n;i++)
		if (!exclusion[i] && refCount[i]>=n-1) {printf("%d\n",i); found=1;}
	
	if (!found) printf("NOT FOUND\n");

	free(exclusion);
	free(refCount);

	return 0;
}
/**
 * ? ? ??????
 * ?    ?????
 * ????: 2010?12?09?
 * ???????n????????????????????????NOT FOUND
*/
int main()
{
	int a[10000][2], b[10000] = {0}, c[10000] = {0};		//??????????????????b?????????????c???????????
	int i, j, n, x, y;					//????x?y??0,0
	int max;							//????max?????????
	int (*p)[2];
	p = a;
	cin >> n;
	for ( i = 0; i < n - 1; i++ )
		for ( j = 0; j < 2; j++ )
			cin >> *(*(p+i)+j);
	cin >> x >> y;						//??0,0
	for ( i = 0; i < n - 1; i++ )		//??????????
		b[*(*(p+i)+0)]++;
	for ( i = 0; i < n - 1; i++ )		//???????????
		c[*(*(p+i)+1)]++;
	max = c[0];
	for ( i = 0; i < n; i++ )
		if ( c[i] > max )
			max = c[i];					//?????????
	for ( i = 0; i < n; i++ )
		if ( b[i] == 0 && c[i] == max )		//????????????????????
			{
				cout << i << endl;			//?????????????
				break;					
			}
		if ( i == n )						//????????????????
			cout << "NOT FOUND" <<endl;
	return 0;       
}
int main()
{
	int n , i ;
	cin >> n;
	int a[n] , b[n] ;
	for ( i = 0 ; i < n; i++ )
		{
		a[i] = 0 ;
		b[i] = 0 ;
		}
	int x , y ;
	while ( cin >> x >> y )
	{
		if ( x == 0 && y == 0 )
			break;
		a[x]++;
		b[y]++;
	}
	for ( i = 0 ; i < n ; i++ )
	{
		if ( a[i] == 0 && b[i] == n - 1 )
			{
			cout<< i ;
			return 0 ;
			}
	}
	cout << "NOT FOUND";
	return 0;
}
int main()
{
    int n;
    int a[100000];
    cin>>n;
    for (int i=0;i<n;i++) a[i]=0;
    int i,j;
    cin>>i>>j;
    while (i!=0||j!=0)
    {
          a[j]++;
          cin>>i>>j;
    }
    for (int i=0;i<n;i++) 
        if (a[i]==n-1) cout<<i<<endl;

    return 0;
}
main()
{
    int n,i,j,N=0;
    scanf("%d\n",&n);
    int p1[100000]={1},p2[100000]={1};
    for(i=0;;i++)
    {
        scanf("%d %d",&p1[i],&p2[i]);
        if((p1[i]==0)&&(p2[i]==0)) break;
    }
    int t,s,num=0;
    for(t=0;t<n;t++)
    {
        for(j=0,s=0;j<i;j++)
        {
            if(p1[j]==t)break;
            if(p2[j]==t)s++;
        }
        if(j==i&&s==n-1)
        {
            printf("%d",t);
            num=1;
        }
    }
    if(num==0)printf("NOT FOUND");
}
int c[9000][9000];
int main()
{
	int n, i, j, a[9000], b[9000], d[9000], sum;
	cin >> n;
	i = 0;
	memset(c, 0, sizeof(c));
	memset(d, 0, sizeof(d));
	while(1)
	{
		cin >> a[i] >> b[i];
		if (a[i]==0&&b[i]==0)
			break;
		if (a[i]==b[i])
			continue;
		c[a[i]][b[i]]=1;
		i++;
	}
	for (i = 0; i < n; i++)
	{
		if (d[i]==1)
			continue;
		for(j = 0; j < n; j++)
		{
			if (i == j)
				continue;
			if (c[i][j]==1)
			{
				d[i]=1;
				break;
			}
			if (c[i][j]==0)
			{
				d[j]=1;
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		if (d[i]==1)
			continue;
		sum = 0;
		for (j = 0; j < n; j++)
			sum+=c[j][i];
		if (sum == n-1)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << "NOT FOUND" << endl;
	return 0;
}
//????????????
//???2010.12.13
//??????
//???1000012856

int main()
{
	int n, count[10000] = {0};
	cin >> n;
	while(1)
	{
		int i, j, k;
		cin >> i >> j;
		if( i == 0 && j == 0)
			break;
		else
		{
			for(k = 0; k < n; k++)
				if(j == k)
					count[k]++;
		}
	}
	int l, sum = 0;
	for(l = 0; l < n; l++)
	{
		if(count[l] == n - 1)
		{
			cout << l << endl;
			sum++;
		}
	}
	if(sum == 0)
		cout << "NOT FOUND" << endl;

	return 0;
}
int main()
{
	int n,i,j,m = -1;
	int a[10000]={0},b[10000]={0};
	cin >> n;
	while (cin >> i >> j)
	{
		if (i == 0 && j == 0) break;
		a[i]++;
		b[j]++;
	}
	for (i = 0 ; i < n ; i ++)
	{
		if(a[i] == 0 && b[i] == n-1 )
		{
			if (m == -1)
			{
				m = i;
			}
			else
			{ 
				m = -1;
				break;
			}
		}
	}
	if (m == -1)
	{
		cout <<"NOT FOUND"<<endl;
	}
	else cout << m <<endl;
}
main()
 {  long int a[100000],b[100000],c[100000],d,e,i,m,n,p,q,f[100000];
    scanf("%d",&n);
    for(i=0;i<100000;i++)
    {scanf("%d %d",&a[i],&b[i]);
    if(a[i]==0&&b[i]==0)
    break;d=i;}  
    for(m=0;m<=n-1;m++)
    {c[m]=0;}
    for(m=0;m<=n-1;m++) 
    {for(i=0;i<=d;i++)
    {if(b[i]==m){c[m]++;}}}
    for(m=0;m<=n-1;m++) 
    {f[m]=c[m];}
    for(m=0;m<=n-2;m++) 
    {if(f[m]>=f[m+1])f[m+1]=f[m];}
    
    for(m=0;m<=n-1;m++) 
    {if(c[m]==f[n-1])
     {if(c[m]>=n-1)
    printf("%d",m);
    else printf("NOT FOUND");}}
    getchar();getchar();getchar();getchar();
}
int main()
{
	int n, i, j, k;
	char **map;
	
	scanf("%d", &n);
	map = (char**)malloc(n*sizeof(char*));
	for(i=0; i<n; i++)
		map[i] = (char*)malloc(n*sizeof(char));
	for(i=0; i<n; i++)
		for(j=0; j<n; j++)
		{
			if(i==j)
				map[i][j] = 1;
			else
				map[i][j] = 0;
		}
	while(scanf("%d %d", &i, &j) && i+j!=0)
		map[i][j] = 1;
	
	k = 0;
	for(j=1; j<n; j++)
	{
		if(map[k][j] == 1)
			k = j;
	}
	for(i=0; i<k; i++)
	{
		if(map[i][k]==0 || map[k][i]==1)
		{
			printf("NOT FOUND");
			for(i=0; i<n; i++)
				free(map[i]);
			free(map);
			return 0;
		}
	}
	printf("%d", k);
	for(i=0; i<n; i++)
		free(map[i]);
	free(map);
	return 0;
}
//*************************
//* ??? ??????   *
//* 1200012878 ???     *
//* 12?16?              *
//*************************
struct person
{
	int a;
	int b;
} p[10000] = {{0,0}};
int main()
{
	int n, flag = 0, i, j;
	cin >> n;
	do
	{
		cin >> i >> j;
		if (i == 0 && j == 0)
			break;
		else
		{
			p[i].a++;
			p[j].b++;
		}
	} while(1);
	for (i = 0; i < n; i++)
	{
		if (p[i].a == 0 && p[i].b == n - 1)
		{
			flag = 1;
			cout << i << endl;
		}
	}
	if (flag == 0)
		cout << "NOT FOUND" ;
	return 0;
}
int main()
{
      int *p;
      int i,j,n,aaa,h ;
      scanf("%d",&n);
      p=malloc(n*sizeof(int));
      for(h=0;h<=n-1;h++)
      {
            *(p+h)=0;
      }
      for(h=0;;h++)
      {
            scanf("%d %d",&i,&j);
            if ((i==0)&&(j==0))
            break;
            *(p+i)=-1;
            if (*(p+j)==-1)
            ;
            else
            {
                  *(p+j)+=1;
            }
      }
      aaa=0;
      for(h=0;h<=n-1;h++)
      {
            if (*(p+h)==n-1)
            {
                  printf("%d",h);
                  aaa=1;
            }
      }
      if (aaa==0)
      {
            printf("NOT FOUND");
      }
      free (p) ;
      return 0;
}
int main()
{
    int n, i, j;
    scanf("%d", &n);
    
    /* initialization */
    char **r_matrix = (char **)malloc(sizeof(char *) * n);
    for(i = 0; i < n; ++i)
    {
        r_matrix[i] = (char *)malloc(sizeof(char) * n);
        for(j = 0; j < n; ++j)
        {
            if(i == j)
                r_matrix[i][j] = 1;
            else
                r_matrix[i][j] = 0;
        }
    }

    /* input */
    while(1)
    {
        scanf("%d %d", &i, &j);
        if(!( i || j ))
            break;
        r_matrix[i][j] = 1;
    }

    int vip = 0, not_found = 0;
    for(i = 0; i < n; ++i)
        if(r_matrix[vip][i])
            vip = i;
    
    for(i = 0; i < vip; ++i)
    {
        if(i == vip)
            continue;
        if(!(r_matrix[i][vip] && !r_matrix[vip][i]))
        {
            not_found = 1;
            break;
        }
    }
    if(not_found)
        printf("NOT FOUND\n");
    else
        printf("%d\n", vip);

    for(i = 0; i < n; ++i)
        free(r_matrix[i]);
    free(r_matrix);
    return 0;
}
int a[1000005],b[1000005],va,vb;
int main()
{
	int n,time=0,much,flag=0;
	cin>>n;
	cin>>va>>vb;
	while((va!=0)||(vb!=0))
	{
		a[time]=va;
		b[time]=vb;
		time++;
		cin>>va>>vb;
	}
	a[time]=va;
	b[time]=vb;
	for(int i=0;i<n;i++)
	{
		much=0;
		for(int j=0;j<=time;j++)
		{
			if(b[j]==i)
			much++;
		}
		if(much>=n-1)
		{
			flag=1;
			for(int j=0;j<=time;j++)
			{
				if((a[j]==i)&&(b[j]!=i))
				{
						flag=0;
						break;
				}
			}
			if(flag==1)
			{
				cout<<i<<endl;
				break;
			}
		}
	}
	if(flag==0)
	cout<<"NOT FOUND"<<endl;

	return 0;
}
// ???????? 
 // ??????
 // ???2010?12?10?
 // ?????????


int main()
{
	int n , i , j , k , a[100000] , b[100000] , c[100000] = { 0 } , g = 0 ; // g????????????                       
	cin >> n ;
	for ( i = 0 ; ; i++ )
	{
		cin >> a[i] >> b[i] ;
		if ( a[i] == 0 && b[i] == 0 )                                   // ??????
			break;
	}
	for ( j = 0 ; j <= i - 1 ; j++ )                                 // ?????????????????
	{
		c[b[j]] = c[b[j]] + 1 ;
	
	}
	for ( k = 0 ; k <= n - 1 ; k++ )                               // ???????????????
	{
		if ( c[k] == n - 1 )
		{
			if ( g == 0 )
			{
				cout << k ;
				g = 1 ;
			}
			else 
			{
				cout << " " << k ;
			}
		}
			
	}
	if ( g == 0 )
		cout << "NOT FOUND" << endl ;
	return 0 ;
}
int main()
{
 int n,a[100000],b[100000],A[100000]={0},B[100000]={0},c=0,num=0,bp=0;
 scanf("%d",&n);
 for(int i=0;;i++)
         {scanf("%d %d",&a[i],&b[i]);
          if(a[i]==0&&b[i]==0)break;
          else
          num++;
          
          }
 for(int i=0;i<n;i++)
        {
         for(int j=0;j<num;j++)
         {if(a[j]==i)
         A[i]++;         
         if(b[j]==i)
         B[i]++;}            
        }
 for(int i=0;i<n;i++)
        {
         
         if(A[i]==0&&B[i]==n-1)
               {
                printf("%d",i);
                c++;               
               }
                                             
        }
 if(c==0)
 printf("NOT FOUND");
 getchar(); 
 getchar();    
}
main()
{
 int i,a,b,n,flag=0,c[10100],d[10100];
 scanf("%d",&n);
 while (scanf("%d%d",&a,&b)==2)
 {
   if (a==0&&b==0)
     break;
   c[b]++;
   d[a]++;     
 }
 for (i=0;i<=n-1;i++)
 if (c[i]==n-1&&d[i]==0)
  {
    printf("%d",i);
    flag=1;                        
  }
 if (flag==0) 
   printf("NOT FOUND\n");
   getchar();
   getchar();
   getchar();
   getchar();
   return 0;    
}
//????
//???????????????????????????????????????????????????????
int sta[10000];  //???n???????? sta[i] ???i????

int main()
{
	int n, x, y;
	cin >> n;
	while ( 1 ) {
		cin >> x >> y;  
		if ( !x && !y ) break;   //0 0 ????
		else ++sta[y];           //y??????????????????+1
	}

	int i;
	for ( i = 0; i != n; ++i ) {
		if ( sta[i] == n - 1 ) {
			cout << i << endl;   //??????????????????
			break;
		}
	}
	if ( i == n ) cout << "NOT FOUND" << endl;

	return 0;
}
int main()
{
    int n,r=0;
    cin>>n;
    int a[10000],b[10000];
    int x=0;
    for(int i=0;;i++)
      {
       cin>>a[i]>>b[i];
        if(a[i]==0&&b[i]==0)
         break;
       x++;
       }
     
    int sum2=0,sum1=0;
    for(int i=0;i<n;i++)
    {
        sum1=0;
        sum2=0;
      for(int j=0;j<x;j++)
      {
         sum1+=(a[j]==i);
      }
         if(sum1==0)
         {
            for(int k=0;k<x;k++)
              if(b[k]==i)
                 sum2+=a[k];
            if(sum2==(n*(n-1)/2-i))
              {
                cout<<i;
                r=1;
              }
         }    
         else continue;
        
    } 
    
 if(r==0)  cout<<"NOT FOUND";


 return 0;
 }
int main()
{
     int a[10000],b[10000];
     int i,j,flag,m,n;
     scanf("%d",&n);
     for(m=0;m<n;m++)
        {
         a[m]=0;b[m]=0;
        }
         for(;;)
           {               
           scanf("%d %d",&i,&j);
           if(i==0&&j==0)
           break;
           else
           {
            a[i]++;b[j]++;  
            }   
           
           }
              for(j=0,flag=0;j<n;j++)
              {
                if(b[j]==(n-1)&&a[j]==0)
                   {
                       printf("%d",j);
                       flag=1;
                    }
              }
     if(flag==0)
     printf("NOT FOUND\n");
     return 0;
     
}
// ??????.cpp : ??????????????
//



int main()
{
	struct celebrity
	{
		int num;
		int no;
	}knowed[10000];
	int x = 0,y = 0,temp,n,j = 0,k = 0,ins;
	cin >> n;
	for (;;)
	{
		cin >> temp;
		cin >> ins;
		if (temp + ins == 0)
		{
			break;
		}
		if (knowed[ins].num < 0)
		{
			knowed[ins].num = 0;
		}
		if (knowed[ins].num >= 0)
		{
			knowed[ins].num++;
		}
	}
	for (j = 0;j <= n - 1;j++)
	{
		if (knowed[j].num == n - 1)
		{
			cout << j << endl;
			y = 1;
			break;
		}
	}
	if (y == 0)
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
int main()
{
int i,j,e,n,a[10000],b[10000];
scanf("%d",&n);
e=0;
i=1;
j=1;
for(int k=0;k<n;k++){
        a[k]=0;
        b[k]=0;
        }


while(i!=0||j!=0){
        scanf("%d %d",&i,&j);
        a[i]++;
        b[j]++;
        }
        a[0]--;
        b[0]--;
for(int k=0;k<n;k++){
    if(a[k]==0&&b[k]==n-1){
                       e=1;
                       printf("%d",k);
                       }    
        }
    if(e==0){
             printf("NOT FOUND");
             }




return 0;
}
int main()
{
	int n;int a[50000];int b[50000];int i;
	for(i=0;i<50000;i++)
	{
		a[i]=0;
		b[i]=0;
	}
	cin>>n;
	int m,p;
	for(i=0;i<50000;i++)
	{
		cin>>m>>p;
		if(m==0&&p==0)
			break;
		if(m!=p)
		{
		a[m]=1;
		}
		b[p]=b[p]+1;
	}
	for(i=0;i<n;i++)
	{
		
		if(a[i]==0&&b[i]>=n-1)
		{
			cout<<i<<endl;
			return 0;
		}

	}
	cout<<"NOT FOUND"<<endl;
	return 0;
}
void main()
{
int a[10000]={0},b[10000]={0},n,i,j,t;
scanf("%d",&n);
do 
{
scanf("%d %d",&i,&j);
if ((i+j)!=0)
{
a[j]=a[j]+1;
b[i]=b[i]+1;
}
}
while ((i+j)!=0);
//for (i=0;i<n;i++){printf("%d %d\n",a[i],b[i]);}
j=0;
for (i=0;i<n;i++) if ((a[i]==(n-1))&&(b[i]==0))
{ t=i;j=j+1;}
if (j<=0) printf("NOT FOUND\n"); else printf("%d\n",t);

//if (j==0)printf("%d\n",j);
}
main()
{
      int n,a=1,b=1,c[10000],i,t,y=0;
      scanf("%d",&n);
      for(i=0;i<n;i++) c[i]=n;
      while(a!=0||b!=0)
      {
          scanf("%d %d",&a,&b);
          if(a==0&&b==0) break;
          else
          {
          c[a]=0;
          if(c[b]!=0) c[b]++;
          }
          }

      for(i=0;i<n;i++)
      {
          if (c[i]==2*n-1) 
          {
            t=i;
            y=1;
            break;
            }
            }
            if(y) printf ("%d\n",t);
            else printf("NOT FOUND\n");
      }
const int N = 1000000;
int cnt[N] = {0};
int main()
{
	int n;
	cin >> n ;
	int a, b;
	int ans = -1;
	while (true)
	{
		cin >> a >> b;
		if ( a == 0 && b == 0) break;
		cnt[b]++;
		if (cnt[b] == n-1)
			ans = b;
	}
	if (ans == -1)
		cout << "NOT FOUND" << endl;
	else
		cout << ans << endl;
}
/*
*12-4
*??? 1200012851
*2012.12.11
*??????
**/


int main()
{
	int i, n, man[10000] = {0}, a, b, flag = 0;
	cin >> n;
	while (1)
	{
		cin >> a >> b;
		if (a == 0 && b == 0)
		{
			break;
		}
		man[a] = -1;
		man[b]++;
	}
	for (i = 0; i < n; i++)
	{
		if (man[i] == n - 1)
		{
			cout << i << endl;
			flag = 1;
		}
	}
	if (flag == 0)
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
main()
{
 int n,a[1000000][2],i,j,sum[1000000],t;
 scanf("%d",&n);
 scanf("%d %d",&a[0][0],&a[0][1]);
 for(i=1;a[i-1][0]!=0||a[i-1][1]!=0;i++)
   scanf("%d %d",&a[i][0],&a[i][1]);
 for(j=0;j<n;j++)
 {sum[j]=0;
  for(i=0;a[i][0]!=0||a[i][1]!=0;i++)
  {if(a[i][0]==j)
   break;
  else
   if(a[i][1]==j)
    sum[j]++;}
    if(sum[j]==n-1)
     {t=1;
      printf("%d",j);
     break;}}

  
 if(t==0)
  printf("NOT FOUND");
   
}
int n,a[10000];
void read(){
	int i,j;
	for (scanf("%d%d%d",&n,&i,&j); i+j!=0;scanf("%d%d",&i,&j)){
		a[j]++;
	}
}

	
int main(){
	int i;
	read();
	for (i=0;i<n;i++)
		if (a[i]==n-1) printf("%d\n",i);
	return 0;
}
int main()
{
	const int N=10000;
	int a[N]={0},b[N]={0};
	int n;
	scanf("%d",&n);
	int x,y;
	scanf("%d%d",&x,&y);
	while(x || y)
	{
		a[x]=1;
		b[y]++;
		scanf("%d%d",&x,&y);
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]) continue;
		if(b[i]==n-1) 
		{
			printf("%d",i);
			exit(0);
		}
	}
	printf("NOT FOUND");
	return 0;
}
main()
{
  int n,c,i,d,s;
  int a[10000];
  for(i=0;i<=9999;i++) a[i]=1;
  int b[10000]={0};
  scanf("%d",&n);
  scanf("%d %d",&c,&d);
  for(;(c!=0)||(d!=0);)
  {
    b[d]++;
    a[c]=0;
    scanf("%d %d",&c,&d);
  }
  s=0;
  for(i=0;(i<=n-1)&&(b[i]=n-1);i++)
  {
    if(a[i]!=0) {printf("%d\n",i);s++;}
  }
  if(s==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;
              break;
          }            
      }
     if(k!=0)
     printf("%d",j);
     else
     printf("NOT FOUND");
    
           
        getchar ();
        getchar ();
        return 0;
}
/**
 * @file    1.cpp              
 * @author  ??? 1100013230               
 * @date    2011-12-7     
 * @descrption        
 *          ??????:??????
*/
int main()
{
	int flag1[10000] = {0}, flag2[10000] = {0}, a, b, n, flag = 0, i;
	cin >> n;                             // n????
	cin >> a >> b;
	while (a != 0 || b != 0)              // ?????0 0?????
	{
		flag1[a]++;                       // a??????1
		flag2[b]++;                       // ??a????1
		cin >> a >> b;
	}
	for (i = 0; i < n; i++) 
		if (*(flag1 + i) == 0 && *(flag2 + i) == n - 1)  // ?i??????0???i????n - 1??i?????
		{
			cout << i;                                   // ??i
			flag = 1;                                    // flag???????????
		}
	if (!flag)                                           // ?????????"NOT FOUND" 
		cout << "NOT FOUND" ;
	return 0;
}
int t[10000000];
int main(){
    int n, i, j;
    scanf("%d", &n);
    while(scanf("%d%d", &i, &j), i||j){
        t[j]++;
        t[i]--;
    }
    for(i = 0; i< n; i++){
        if(t[i] == n-1){
             printf("%d", i);
             break;
        }
    }
    if(i == n)printf("NOT FOUND");
    return 0;
}
//****************************************
//*??????                   **
//*??? 1100012927              **
//*2011.11.29                     **
//****************************************

int main()
{
    int n, per1 = 1, per2 = 1, knows[10000] = {0}, knowed[10000] = {0}, count = 0, i = 0;
    int *p = knows;
    int *q = knowed;
    cin >> n;
    do
    {
        cin >> per1 >> per2;
        if (per1 != 0 || per2 != 0)
        {
            *(p + per1) = 1;
            (*(q + per2))++;
        }
        else
            break;
    }while(1);
    for (i = 0; i < n; i++)
    {
        if (*(p + i) == 0 && *(q + i) == n - 1)
        {
            if(count == 0)
            {
                cout << i;
                count++;
            }
            else
            {
                cout <<' '<< i;
                count++;
            }
        }
    }
    if (count == 0)
        cout <<"NOT FOUND";
         return 0;
        
}
int n;
int r[M][2];
int rn;
int p[M];

int wk;

void cal()
{
    int i,j;
    wk = -1;
    for (i=0; i<n; i++)
	p[i] = 1;
    for (i=0; i<rn; i++)
	p[r[i][0]] = 0;
    for (i=0; i<n; i++) {
	if (p[i] == 1) {
	    if (wk != -1) {
		wk = -1;
		return;
	    }
	    else wk = i;
	}
    }
    if (wk == -1) return;

    for (i=0; i<n; i++)
	p[i] = 1;
    for (i=0; i<rn; i++)
	if (r[i][1] == wk)
	    p[r[i][0]] = 0;
    j=0;
    for (i=0; i<n; i++)
	j += p[i];
    if (j != 1)
	wk == -1;
}

void input()
{
    scanf("%d", &n);
    rn = 0;
    while (scanf("%d%d", &r[rn][0], &r[rn][1])!=EOF && (!(r[rn][0]==0 && r[rn][1]==0)))
	rn ++;
}

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

int main()
{
    input();
    cal();
    output();
    return 0;
}