semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int n,j,x,i=0,m,k=0,num=0,num1=0;
    int a[1000000],b[1000000],c[100];
    scanf("%d",&n);
    while(1)
    {
            scanf("%d %d",&a[i],&b[i]);
            if(a[i]==0&&b[i]==0) 
            break;
            else i++;
    }
    for (x=0;x<n;x++)
    {
        m=0;
        for(j=0;j<i;j++)
        {
                        if(a[j]==x)
                        {
                                   m=1;
                                   break;
                        }
        }
        if (m==0)
        {
                 c[k]=x;
                 k++;
        }
    }
    if(k==0) printf("NOT FOUND");
    else
    { 
    for(j=0;j<k;j++)
    {
                    for(x=0;x<i;x++)
                    {
                                    if(b[x]==c[j])
                                    num++;
                    }
                    if(num==n-1) 
                    {
                                 printf("%d",c[j]);
                                 num1++;
                    }
    }
    if (num1==0)  printf("NOT FOUND");
    }
    getchar();
    getchar(); 
}
int main()
{
	int flag = 1;
    int n, a[100000] = {0}, b[100000] = {0}, c[10000] = {0}, d[10000] = {0};
    cin >> n;
    int *p = a, *q = b;
    for (int i = 0; ; i++)
    {
		cin >> *(p + i) >> *(q + i);
        if (*(p + i) == *(q + i) && *(p + i) == 0)
			break;
        c[*(q + i)]++;
        d[*(p + i)]++;
        if (c[*(q + i)] == n - 1 && d[*(q + i)] == 0)
        {
            cout << *(q + i);
            flag = 0;
        }
    }
    if (flag == 1)
        cout << "NOT FOUND";
    return 0;
}
int main()
{
	int n;
	int i,j;
	cin>>n;
	int know[10000][2] = {0}; //??????????,???????????
	int *p;
	int flag = 0;//????????
	p = &know[0][0];//??????????
	while(1)
	{
		cin>>i>>j;
		if (i == 0 && j == 0)
			break;
		*(p + i * 2) += 1;//i?????+1
		*(p + j * 2 + 1) += 1;//??j???+1
	}
	for (i = 0; i <= n - 1;i++)
	{
		if (*(p + i * 2) == 0 && *(p + i * 2 + 1) == n - 1)//????0?,?n-1???,???? 
		{
			cout<<i<<endl;
			flag = 1;
		}
	}
	if (flag == 0)
		cout<<"NOT FOUND";
	return 0;
}
void main()
{
int n,a[100000],b[100000],l,i=0,j,k;
scanf("%d\n",&n);
scanf("%d %d\n",&a[0],&b[0]);
while(!(a[i]==0&&b[i]==0))   {i++;scanf("%d%d",&a[i],&b[i]);}
for(j=0;j<n;j++)
{ l=0;
  for(k=0;k<i;k++)
 {
  if(a[k]==j)    break;
  else if(b[k]==j)   l++;}
  if(l==n-1)   break;}
if(j==n)  printf("NOT FOUND");
else printf("%d",j);
}
int main()
{
	int n, a, b, i, f = 1;

	typedef struct P
	{
		int known;
		int know;
	}peo;
	peo * p;
	scanf("%d", & n);
	p = (peo *)malloc(sizeof(peo) * n);

	for(i = 0; i < n; i++)
	{
		p[i].know = 0;
		p[i].known = 0;
	}

	scanf("%d%d", & a, & b);
	for(; ! (a == 0 && b == 0); )
	{	
		p[a].know++;
		p[b].known++;	
		scanf("%d%d", & a, & b);
	}
	for(i = 0; i < n; i++)
	{
		if((p[i].know < n - 1) && (p[i].known == n - 1))
		{
			f = 0;
			printf("%d",i);
		}
	}
	if(f)
		printf("NOT FOUND\n");
}
int main()
{
    int i,n,p=0,r,x,y,*b;
    scanf("%d",&n);
    b=(int*)malloc(n*sizeof(int));
    for (i=0;i<=n-1;i++)
    b[i]=0;
    while (1)
    {
        scanf("%d %d",&x,&y);
        if ((x==0)&&(y==0))
        break;
        b[x]=-1;
        if (b[y]!=-1) b[y]++;
    }
    for (i=0;i<=n-1;i++)
    if (b[i]!=-1) {p++;r=i;}
    if (p!=1) printf("NOT FOUND");
    else
    if (b[r]==n-1)
    printf("%d",r);
    else
    printf("NOT FOUND");
}
int main()
{
	int n, i, j, k;
	int *p1,*p2;
	int flag=0;
	int person[10000] = {0},count[10000] = {0};
	cin >> n;
	cin >> i >> j;
	p1 = &person[j];
	p2 = &count[i];
	while(i!=0||j!=0)
	{
		(*p1)++;
		count[i]++;
		cin >> i >> j;
		p1 = &person[j];
	    p2 = &count[i];

	}
		
	for(k=0;k<n;k++)
		if(person[k]==n-1&&count[k]==0)
		{
			cout << k << endl;
			flag = 1;
		}
	if(flag==0)
		cout << "NOT FOUND" << endl;

	return 0;
}
// ?????? ?? 1000062708
int main()
{
	int n, i, j, a[100000] = {0};
	cin >> n;
	do
	{
		cin >> i >> j;
		a[i]--;
		a[j]++;
	}while(i != 0 || j != 0);
	for(i = 0;i < n;i++)
		if(a[i] == n - 1)
		{
			cout << i << endl;
			break;
		}
	if(i == n)
		cout << "NOT FOUND" << endl;
	return 0;
}
main()
{ 
      int n,a,b,i,k;
      int *p=(int*)malloc(n*sizeof(int));
      int *q=(int*)malloc(n*sizeof(int));
      scanf("%d",&n);
      for(i=0;i<n;i++)
         { 
          p[i]=0;
         q[i]=0; 
         }
      for(k=0;;k++)
      {
         scanf("%d %d",&a,&b);
         if(a==0&&b==0)
         break;
         for(i=0;i<n;i++)
         {
                        
            if(a==i)
            {p[i]=p[i]+1;}
            if(b==i)
            {q[i]=q[i]+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");
            }
            
            
 
   getchar();
      getchar();
      getchar();
      getchar();
}
int main()
{
    int i=0,j,n,judge=0;
    cin>>n;
    int peo1[n],peo2[n];
    int countNum[n];
    for(i=0;i<n;i++)
    {
        countNum[i]=0;
    }
    while(1)
    {
        cin>>peo1[i]>>peo2[i];
        if(peo1[i]==0&&peo2[i]==0)  break;
        else    countNum[peo2[i]]++;
    }
    for(i=0;i<n;i++)
    {
        if(countNum[i]==n-1)
        {
            cout<<i<<endl;
            judge=1;
        }
    }
    if(judge==0) cout<<"NOT FOUND";
    return 0;
}
main()
{
      int n,i,k=0,a,b;
      int str[10000]={0},f[10000]={0};
      scanf("%d",&n);
      for(;;)
      {
             scanf("%d %d",&a,&b);
             if(a==0&&b==0) break;
             str[b]+=a;
             f[a]++;
      }
      for(i=0;i<n;i++)
      {
                      if(str[i]==((n-1)*n/2-i)&&f[i]==0)
                      {printf("%d",i);k++;}
      }
      if(k==0) printf("NOT FOUND");
      printf("\n");

}
int main()
{
	int n, a[99999] , b[99999] = {0}, *p = a, *q = b, flag = 0;
	cin >> n;
	int k, i, j;
	for ( k = 0; k < n; k++,p++ )
	{
		*p = -1;
	}

	while ( cin >> i )
	{

		cin >> j;
		if ( i == 0 && j == 0 )
			break;
		a[i] = j; //a?i????
		b[j]++;  //b???j???
	}
	p = a;
	for ( k = 0; k < n; k++, p++, q++ )
	{
		if ( *q == n - 1 && *p == -1 )
		{
			cout << k << endl;
			flag = 1;
		}
	}
	if ( flag == 0 )
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
main()
{
      int n,*p,i,j,a,b;
      scanf("%d",&n);
      p=(int *)malloc(n*sizeof(int));
      for(i=0;i<n;i++) p[i]=0;
      scanf("%d%d",&a,&b);
      while(a!=0 || b!=0)
      {
            p[b]++;
            scanf("%d%d",&a,&b);
      }
      for(i=0;i<n;i++) if(p[i]==n-1) {printf("%d",i);break;}
      if(i==n) printf("NOT FOUND");
}
int main()
{
	int people[100000] = {0};
	int n , num1 , num2 ,flag = 0;
	cin>>n;
	for( ;; )
	{
		cin>>num1>>num2;
		if( num1 == 0 && num2 == 0)
		{
			for( int i = 0 ; i < n ; i++)
	        {
		       if( people[i] == n - 1)
		       {
			       flag = 1;
			       cout<<i<<endl;
		       }
	        }
	        if( flag == 0)
	        {
		         cout<<"NOT FOUND"<<endl;
	        }
			return 0;
		}
		else
		{
			people[num2]++;
		}
	}
	

}
int main()
{
	int i,a,b,n;
	int TRUE=1;
	int left[10000]={0};
	int right[10000]={0};
	scanf("%d",&n);
	while(TRUE)
    {
		scanf("%d%d",&a,&b);
		left[a]++;
		right[b]++;
		if(a==0&&b==0)      break;
	}
    left[0]=left[0]-1;
    right[0]=right[0]-1;
	for(i=0;i<n;i++)
    {
		if(right[i]==n-1&&left[i]==0)
        {
			printf("%d\n",i);
			TRUE=0;
		}
	}
	if(TRUE)   printf("NOT FOUND\n");
	return 0;
}
int main()
{
	int num;
	int i,j;
	int* relation;
	scanf("%d",&num);
	relation = (int*)malloc(sizeof(int)*num*num);
	assert(relation!=NULL);

	memset(relation,0,num*num*sizeof(int));

	i=1;
	j=1;

	while(!(i==0&&j==0))
	{
		scanf("%d %d", &i, &j);
		relation[j*num+i] = 1;
	}

	j=0;
	for (i=1;i<num;i++)
	{
		if (!relation[j*num+i])
			j = i;
	}

	for ( i=0;i<num;i++)
	{
		if ( i!=j )
			if (!relation[j*num+i])
			{
				printf("NOT FOUND");
				return 0;
			}
	}

	printf("%d",j);
	return 0;

}
int main()
{
	int n, x, y, j, flag;
	int know[10000], beknown[10000];
	while(cin>>n)
	{
		memset(know, 0, sizeof(know));
		memset(beknown, 0, sizeof(beknown));
		while(1)
		{
			cin>>x>>y;
			if(x==0 && y==0)
				break;
			know[x]++;
			beknown[y]++;
		}
		flag = false;
		for(j=0; j<n; j++)
			if(know[j]==0 && beknown[j]==n-1)                       //????????????
			{
				flag = true;
				cout<<j<<endl;
			}
		if(!flag)
			cout<<"NOT FOUND"<<endl;
	}
	return 0;
}
int main()
{
	int n,i,j,k,g=0;
	int a[10000]={0};
	cin>>n;
	while(cin>>i>>j)
	{
		if(i==0&&j==0)
			break;
		else
			a[j]++;
	}
	for(k=0;k<n;k++)
	{
		if(a[k]==n-1)
		{
			cout<<k<<endl;
		    g=1;
		}
	}
	if(g==0)
		cout<<"NOT FOUND";
	return 0;
}
int know(int **a, int n, int i, int j)
{
	return (a[(i%n)>>5][j%n] & (1<<((i%n)&0x1f))) ? 1 : 0;
}

void set(int **a, int n, int i, int j)
{
	a[(i%n)>>5][j%n] |= 1<<((i%n)&0x1f);
}

int ** read_data(int n) 
{
	int i, j;
	int **a = (int **)malloc(n * sizeof(int *) / 32);
	for (i = 0; i < n / 32; i++) 
	{
		a[i] = (int *)malloc(n * sizeof(int));
		memset(a[i], 0, (n * sizeof(int)));
	}
	for (;;)
	{
		scanf("%d%d", &i, &j);
		if (i == 0 && j == 0) 
			break;
		set(a, n, i, j);
	}
	return a;
}

void free_data(int **a, int n)
{
	int i;
	for (i = 0; i < n / 32; i++) 
	{
		free(a[i]);
	}
	free(a);
}

int main()
{
	int i, j, n, next, k, wrong, candidate;
	scanf("%d", &n);
	int **a = read_data(n);
	/*
	for (i = 0; i < n; i++) 
	{
		for (j = 0; j < n; j++) 
		{
			printf("%d", know(a, n, i, j));
		}
		printf("\n");
	}
	*/
	// begin
	i = 0;
	j = 1;
	next = 2;
	while (next <= n) 
	{
		if (know(a, n, i, j))
			i = next;
		else
			j = next;
		next++;
	}
	if (i == n)
		candidate = j;
	else 
		candidate = i;
	wrong = 0;
	k = 0;
	while ( !wrong && k < n )
	{
		if (know(a, n, candidate, k) && (candidate != k))
			wrong = 1;
		if (!know(a, n, k, candidate) && (candidate != k))
			wrong = 1;
		k++;
	}
	if (!wrong)
		printf("%d", candidate);
	else
		printf("NOT FOUND");
	// end
	free_data(a, n);
	return 0;
}
int main()
{
	int n;
	int in[200000],out[200000];
	memset(in,0,sizeof(int));
	memset(out,0,sizeof(int));
	cin>>n;
	int to,from;
	while(cin>>to>>from)
	{
		if(to == 0 && from == 0) break;
		in[from] ++;
		out[to] ++;
	}
	for(int i = 0 ; i < n; i ++)
	{
		if(in[i] == n - 1 && out[i] == 0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"NOT FOUND"<<endl;
	return 0;
}
int main(){
	int n;
	cin>>n;
	int rela1[100000],rela2[100000];
	int i=0,p,I;
	while(1){
		cin>>rela1[i]>>rela2[i++];
		if(rela1[i-1]==0&&rela2[i-1]==0){
			I=i;
			break;
		}}
		int num[n];
		for(p=0;p<n;p++){
			num[p]=0;
			for(int k=0;k<I-1;k++)
				if(rela2[k]==p)num[p]++;
			if(num[p]>=n-1){
				cout<<p<<endl;
				break;
			}
		}
		if(p==n)cout<<"NOT FOUND"<<endl;
	return 0;
}
/*
 * 243.cpp
 *
 *  Created on: 2011-12-22
 *      Author: think
 */
int main(){
	int n;
	cin>>n;
	int knowcount[n];
	int knowncount[n];
	memset(knowcount,0,sizeof(knowcount));
	memset(knowncount,0,sizeof(knowncount));
	int temp1,temp2;
	for(;;){
		cin>>temp1>>temp2;
		if(temp1==0&&temp2==0)break;
		knowcount[temp1]++;
		knowncount[temp2]++;
	}
	int i,count=0;
	for(i=0;i<n;i++){
		if(knowcount[i]==0&&knowncount[i]==n-1){
			cout<<i<<endl;count++;
		}
	}
	if(count==0)cout<<"NOT FOUND"<<endl;
	return 0;
}
int main()
{
	int n,i,j,flag = 1,flag2 = 0,len,count = 0;
	cin >> n;
	int a[100000],b[100000];
	for (i = 0;i < 100000;i++)
	{
		cin >> *(a + i) >> *(b + i);
		if (*(a + i) == 0 && *(b + i) == 0)
		{
			len = i;
			break;
		}
	}
	for (i = 0;i < n;i++)
	{
		count = 0;
		flag = 1;
		for (j = 0;j < len;j++)
		{
			if (*(b + j) == i)
				count++;
		}
		if (count == n - 1)
		{
			for(j = 0;j < len;j++)
				if (*(a + j) == i)
					flag = 0;
			if (flag == 1)
			{
				cout << i << endl;
				flag2 = 1;
			}
		}
	}
	if (flag2 == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
//**********************************************************
//*  ?????3.cpp                                       *
//*  ??????1200012906                                *
//*  ???2012?12?10?                                  *
//*  ???????????                                *
//**********************************************************


int main()
{
	int n, i, j, k[10000] = {0}, flag = 0;
	cin >> n;
	while(cin >> i >> j && i != 0 || j != 0)
	{
		k[j]++;
	}
	for(i = 0; i < n; i++)
		if (k[i] == n - 1)
		{
			cout << i << endl;
			flag = 1;
		}
	if (flag == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main(){
	int i=1,j,k,g,n,c,d,q=0;
	int a[100000],b[100000];
	cin>>n;
	while(1){
		cin>>a[i]>>b[i];
		if(a[i]==0&&b[i]==0)break;
		i++;
	}
	for(k=0;k<n;k++){g=0;
	    d=0;
		for(j=1;j<i;j++){
			if(b[j]==k)g++;
		}
		if(g==n-1){
			for(c=1;c<i;c++){
				if(a[c]!=k)d++;
			}
			if(d==i-1){cout<<k<<endl;
			q++;
			break;
			}
		}
	}
	if(q==0)cout<<"NOT FOUND"<<endl;
	return 0;
}
int main()
{
	int a[10000]={0};
	int n,i,j;
	cin>>n;
	while(cin>>i>>j&&(i!=0||j!=0))
	{
		a[i]=0;
		a[j]++;
	}
	for(i=0;i<=n-1;++i)
		if(a[i]==n-1)
			cout<<i;
	return 0;
	
}
/*
 * 111220_Celebrity.cpp
 *
 *  Created on: 2011-12-23
 *      Author: Alfalfa
 */
int main(){
	int n1;
	cin>>n1;
	const int n=n1;
	int knowother[n],beknown[n],input1=1,input2=1;
	memset(knowother,0,sizeof(knowother));
	memset(beknown,0,sizeof(beknown));
	while(input1||input2){
		cin>>input1>>input2;
		if(input1!=input2) {
			knowother[input1]++;
			beknown[input2]++;
		}
	}
	int celebrity=0,flag=0;
	for(int i=0;i<n;i++){
		if(knowother[i]==0 && beknown[i]==n-1) {
			celebrity=i;
			flag=1;
		}
	}
	if(flag==1) cout<<celebrity;
	else cout<<"NOT FOUND";
	return 0;
}
main()
{
    int n,i,c,d,j;
    scanf("%d",&n);
    int a[n];
    int b[n];
    i=0;
    do
    {
        a[i]=i;
        b[i]=0;
        i=i+1;
    }
    while(i<n);
    do
    {
       scanf("%d %d",&c,&d);
       if(c!=0||d!=0)
       {
           i=0;
           do
           {
               if(d==a[i])
               {
                   b[i]=b[i]+1;
                   break;
               }
               i=i+1;
           }
           while(i<n);
           i=0;
           do
           {
               if(c==a[i])
               {
                   b[i]=0;
                   break;
               }
               i=i+1;
           }
           while(i<n);
       }
    }
    while(c!=0||d!=0);
    i=0;
    j=0;
    do
    {
       if(b[i]==(n-1))
       {
           printf("%d\n",a[i]);
           j=1;
           break;
       }
       i=i+1;
    }
    while(i<n);
    if(j==0) printf("NOT FOUND");
}
void main()
{
 int n,i=0,j=0,k=0,l,m;
 scanf("%d",&n);
 int b[n],c[n];
 while(j<n)
 {
  b[j]=0;
  c[j]=0;
  j++;
 }
 j=0;
 scanf("%d %d",&l,&m);
 b[l]++;
 c[m]++;
 i++;
 while((l+m)!=0)
 {
  scanf("%d %d",&l,&m);
  b[l]++;
  c[m]++;
  i++;
 }
 i--;
 b[0]--;
 c[0]--;
 while(j<n)
 {
  if(b[j]==0&&c[j]==n-1)
   printf("%d",j),j=n,k++;
  j++;
 }
 if(k==0)
  printf("NOT FOUND");
}
int n ;
int i , j;
int in[ 10000] = { 0 } ;
int out[ 10000 ] = { 0 };



int main()
{
	int h ;
	cin>>n ;
	while( cin>>i>>j )
	{
		if( i == 0 && j == 0 )
			break;

		in[ i ] = 1 ;
		out[ j ] = 1 ;
	}

	for( h = 0 ; h < n ; h++ )
	{
		if( in [ h ] == 1 )
		{
			out[ h ] = 0 ;
		}
	}

	int count = 0 ;

	for( h = 0 ; h < n ; h++ )
	{
		if( out[ h ] == 1 )
		{
			cout<<h<<endl ;
			count = 1 ;
		}
	}


	if( count == 0 )
	{
		cout<<"NOT FOUND"<<endl;
	}


	return 0 ;
	
	
}
struct person
{
	int flag;
	int count;
}p[10001];

int main()
{
	int n, i, j, g = 0;
	cin >> n;
	while (1)
	{
		cin >> i >> j;
		if (i == 0 && j == 0) break;
		p[i].flag = 1;
		p[j].count++;
	}
	for (int i = 0; i < n; i++)
	{
		if (p[i].flag == 0 && p[i].count == n - 1) g = 1, cout << i << endl;
	}
	if (g == 0) cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
	int c[10000], n, a, b, answer = 20000;
	memset(c, 0, 100);
	cin >> n;
	while (cin >> a >> b && (a + b!=0))
	{
		c[a] = 1;
	}
	for (int i = 0; i < n; i ++)
	{
		if(c[i] == 0)
		{
			answer = i;
		}
	}
	if (answer != 20000)
	{
		cout << answer << endl;
	}
	else
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
int main()
{
  int n,b[65535],c[65535],i,k;
  scanf("%d",&n);
  int a[n];
   for(i=0;i<n;i++)
  {
   a[i]=0;
  }
  
  
  scanf("%d %d",&b[0],&c[0]);
  a[b[0]]=a[b[0]]-1;
  a[c[0]]=a[c[0]]+1;
  for(k=0;;k++)
  {
     if(b[k]==0&&c[k]==0)
     break;
     else
     {
     scanf("%d %d",&b[k+1],&c[k+1]);
     a[b[k+1]]=a[b[k+1]]-1;
     a[c[k+1]]=a[c[k+1]]+1;
     }
  }
  for(i=0;i<n;i++)
  {
    if(a[i]==(n-1))
    {
      printf("%d",i);
      break;
    }
  }
   getchar();
   getchar();   
}
int main(int argc, char * argv[])
{
    int person[10000];
    int number,a,b,i;
    cin >> number;

    for(i=0;i<number;i++)
        person[i]=0;

    for(i=0;;i++)
  {
    cin >> a >> b;
    if(a==0 && b==0) break;
    person[a]=-1;
    if(person[b]!=-1)person[b]++;
  }

    for(i=0;i<number;i++)
  { 
      if(person[i]==number-1)
      {  cout <<i<< endl;
         break;
      }
  }
    if(i==number)
        cout <<"NOT FOUND"<< endl;
    return 0;
}
int main()
{
	int n,know,a,b,c=0;
	scanf("%d",&n);
	int *p= (int*)malloc(n*sizeof(int)) ;
	int *q= (int*)malloc(n*sizeof(int)) ;
	for(int i=0;i<n;i++)
	{
		q[i]=0;p[i]=0;
	}
	while(1)
	{
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)
			break;
		q[b]=q[b]+1;
		p[a]=1;
	}
	for(int i=0;i<n;i++)
		if(p[i]==0 && q[i]==n-1)
		{
			printf("%d",i);
			c=1;
		}
		if(c==0)
	printf("NOT FOUND");
	return 0;
}
int inDegree[10000];
int outDegree[10000];

int main()
{
	int N;
	cin>>N;
	memset(inDegree,0,sizeof(inDegree));
	memset(outDegree,0,sizeof(outDegree));
	int first,second;
	while(cin>>first>>second)
	{
		if(first==0&&second==0)
			break;
		outDegree[first]++;
		inDegree[second]++;
	}
	int i;
	for(i=0;i<N;i++)
	{
		if(outDegree[i]==0&&inDegree[i]==N-1)
			break;
	}
	if(i==N)
		cout<<"NOT FOUND\n";
	else
		cout<<i<<endl;
	return 0;
}
int main()
{
	long int n,a[20000],b[20000],count[10000]={0},i=0;
	scanf("%d",&n);
	scanf("%d%d",&a[0],&b[0]);
	while(a[i]!=0||b[i]!=0)
	{
		count[a[i]]=1;
		count[b[i]]--;
		i++;
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<n;i++)
		if(count[i]==(-n+1)) 
		{
			printf("%d\n",i);
			return 0;
		}
	printf("NOT FOUND\n");
	return 0;
}
/*
 * xiaoceyan54.cpp
 *
 *  Created on: 2011-1-8
 *      Author: dyj
 *      ?????????n?????n????
 *      ????????i?j???i??j???0?i,j<n?
 *      ???????0 0????????
 *
 *      ????????????????????????NOT FOUND?
 */


int main(){
	int n,i,j,max=0,famous;
	cin>>n;
	int fame[n];
	for(i=0;i<n;i++)
			fame[i]=0;
	while(cin>>i>>j){
		if(i==0&&j==0)
			break;
		fame[j]=fame[j]+1;
	}
	for(j=0;j<n;j++){
		if(fame[j]>=max){
			max=fame[j];
			famous=j;
		}
	}
	if(max>=n-1)
		cout<<famous<<endl;
	else
		cout<<"NOT FOUND"<<endl;
	return 0;
}
int n,a,b,ind[MAXN],oud[MAXN],i;
int main()
{
  scanf("%d",&n); 
  scanf("%d%d",&a,&b);
  while(a+b)
    {
    ind[b]++;
    oud[a]++;  
    scanf("%d%d",&a,&b);     
    } 
  for(i=0;i<n;i++)
    if (ind[i]==n-1&&!oud[i])
      break;
  if (i<n)
    printf("%d\n",i);
  else
    printf("NOT FOUND\n");        
  return 0;
}
int a[10001]={0};
int main(){
	int n,tag,i,j;
	scanf("%d",&n);
	while(1){
		scanf("%d%d",&i,&j);
		if(!(i||j)) break;
		a[i]=1;
	}
	for(int i=0;i<n;i++)
		if(!a[i]){
			printf("%d\n",i);
			return 0;
		}
	printf("NOT FOUND\n");
	/*
	for(int i=0;i<n;i++){
		tag=1;
		for(int j=0;j<n;j++){
			if(i==j) continue;
			if(a[i][j] || !(a[j][i]) ) {
				tag=0;
				break;
			}
		}
		if(tag==1){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("NOT FOUND\n");*/


}
int main()
{
    int a[100001][3];
    int b[3][100001];
    int n,i,j,h,c,d,p;
    h=p=0;
    scanf("%d",&n);
    for(i=1;;i++)
    {
        scanf("%d %d",&a[i-1][0],&a[i-1][1]);
        if(a[i-1][0]==0&a[i-1][1]==0)
        break;
        h=h+1;
    }
    for(i=1;i<=h;i++)
    {
        c=d=0;
        for(j=1;j<=p;j++)
        {
            if(b[0][j-1]==a[i-1][1])
            {
                c=1;
                break;
            }
            d=d+1;
        }
        if(c==0)
        {
            b[0][p]=a[i-1][1];
            b[1][p]=1;
            p=p+1;
        }
        else
        b[1][d]=b[1][d]+1;
    }
    for(i=1;i<=p;i++)
    if(b[1][i-1]==n-1)
    printf("%d\n",b[0][i-1]);
    if(p==0)
    printf("NOT FOUND");
    return 0;
}
//********************************************
//???????????
//??????
//?????2010.12.10
//???????????
//********************************************
int main ()
{
	//??????????????????????????????????count1????????????count2
	int n, a[2], i, num = 0, count1[10000] = {0},count2[10000] ={0};
	cin >> n;
	do
	{
		cin >> a[0] >> a[1];
		if (a[0] ==0 && a[1] == 0)
			break;//??0 0 ?????
		count1[a[0]]++;
		count2[a[1]]++;
	}while(1);
	for ( i = 0; i < n; i++)
	{
		if ( count1[i] == 0 && count2[i] == (n - 1))
		{
			cout << i << endl;//???????????????????????
			num++;//???????1
		}
	}
	if ( num == 0 )
		cout << "NOT FOUND" << endl;//???????????NOT FOUND
	return 0;
}
int main()
{
	int n, i, j, a[100000]={0}, flag = 0;
	cin >> n;
	cin >> i >> j;
	while(i+j)
	{	
		a[j]++;
		cin >> i >> j;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==n-1)
		{
			cout << i << endl;
			flag = 1;
		}
	}
	if(flag == 0)
		cout << "NOT FOUND";
	return 0;

}
int main(){
	int n,i,y=0,j,c,d;
	scanf("%d",&n);
	int a[10001]={0},b[10001]={0};
	for(i=0;;i++){
		scanf("%d %d",&c,&d);
		if((c!=0)||(d!=0)){
			a[d]++;
			b[c]--;
		}
		if((c==0)&&(d==0)){break;}
	}
	for(j=0;j<n;j++){
		if((a[j]==n-1)&&(b[j]==0)){
		 printf("%d\n",j);
		 y=1;
		}
	}
		if(y==0){
			printf("NOT FOUND\n");
		}
	return 0;
}
struct man
{
	int a;
	int b;
}person[10000];
int main()
{
	int n=0;
	int x=0,y=0;
	int i=0;
	cin>>n;
	while(1)
	{
		cin>>x>>y;
		if(x==0&&y==0)
			break;
		person[x].a++;
		person[y].b++;
	}
	for(i;i<n;i++)
	{
		if(person[i].a==0&&person[i].b==n-1)
		{
			printf("%d\n",i);
			break;
		}
	}
	if(i==n)
		printf("NOT FOUND\n");
	return 0;
}
int main()
{
    int n,s,flag=1;
    cin>>n;
    int a[50000],b[50000],sa[n],sb[n];
    for(int i=0;i<n;i++)  sa[i]=sb[i]=0;
    for(s=0;;s++)
    {
    cin>>a[s]>>b[s];
    if(!a[s]&&!b[s])  break;
    }
    for(int i=0;i<s;i++)
    {
    sa[a[i]]++;
    sb[b[i]]++;
    }
    for(int i=0;i<n;i++)
    {
    if(sa[i]==0&&sb[i]==n-1)
    {
    cout<<i<<endl;
    flag=0;
    }
    }
    if(flag)  cout<<"NOT FOUND";
}
main()
{
int n,q,t,i,j,count=0;
int *x,*y;
scanf("%d",&n);
x=(int*)malloc(sizeof(int)*(n+5));
y=(int*)malloc(sizeof(int)*(n+5));
for(q=0;q<=n+3;q++)
{
x[q]=0;
y[q]=0;
}


    for(t=0;;t++)
    {
    scanf("%d %d",&i,&j);
    if(i==0&&j==0){break;}
    x[j]+=1;
    y[i]+=1;
    }

    for(t=0;t<=n-1;t++)
    {
    if(x[t]==n-1&&y[t]==0)
    {
    printf("%d\n",t);
    count+=1;
    }
    }
    if(count==0)
    printf("NOT FOUND");
}
int data[9000];
int main()
{
	int n;
	int i, j;
	scanf("%d",&n);
	scanf("%d%d",&i,&j);
	while((i != 0)||(j != 0))
	{
		data[i] = -1;
		data[j]++;
		scanf("%d%d",&i,&j);
	}
	for (i = 0; i < n; i++)
	{
		if (data[i] == n-1)
		{
			printf("%d\n",i);
			break;
		}
	}
	if (i == n)
		printf("NOT FOUND\n");
	return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2011-12-19
 *      Author: 1100012870
 */
int whoknow[1000000]={0},knowwho[1000000]={0};
int main()
{
	int i,n,x,y;
	cin>>n;
	cin>>x>>y;
	while(!(x==0 && y==0)){
		whoknow[y]++;
		knowwho[x]++;
		cin>>x>>y;
	}
	for(i=0;i<=n;i++)
		if(knowwho[i]==0 && whoknow[i]==n-1){
			cout<<i<<endl;
			return 0;
		}
	cout<<"NOT FOUND"<<endl;
	return 0;
}
int main()
{
	int n;
	int *a,*index;
	int i,j;
	int result;
	cin >> n;
	a = (int *)malloc(n*n*sizeof(int));
	index = (int *)malloc(n*sizeof(int));
	for (i=0;i<n;i++)
	{
		*(index+i) = i;
	}

	while (1)
	{
		cin >> i >> j;

		if (i==0&&j==0)
		{
			break;
		}
		else
		{
			*(a+n*j+i) = 1;
		}
	}

	for (i=n-1;i>=1;i--)
	{
		if (1 == *(a+n*index[i]+index[i-1]))
		{
			index[i-1] = index[i];
		}
	}


	result = -1;
	for (i=0;i<n;i++)
	{
		if(0 == *(a+n*index[0]+i))
		{
			if (index[0]!=i)
			{
				cout << "NOT FOUND";
				free(a);
				a = NULL;
				free(index);
				index = NULL;
				return 0;
			}
		}
	}

	for (i=0;i<n;i++)
	{
		if(1 == *(a+n*i+index[0]))
		{
			cout << "NOT FOUND";
			free(a);
			a = NULL;
			free(index);
			index = NULL;
			return 0;
		}
	}

	cout << index[0];
	free(a);
	a = NULL;
	free(index);
	index = NULL;
	return 0;
}