semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(){
	int n,i,j,sz1[10000],k,sz2[10000],e=0;
	scanf("%d",&n);
	for(k=0;k<n;k++){
		sz1[k]=0;
		sz2[k]=0;
	}

	while(scanf("%d %d",&i,&j),i|j){
		sz1[i]++;
		sz2[j]++;
	}

	for(k=0;k<n;k++){
		if(sz1[k]==0&&sz2[k]==n-1){
			printf("%d",k);
				e++;
		}
	}
	if(e==0)
		printf("NOT FOUND");

	return 0;
}
main()
{
    int n,a,b,i,ncount;
    int they[10000]={0},me[10000]={0};
    scanf("%d",&n);
    for(i=0;;i++)
    {
        scanf("%d",&a);
        scanf("%d",&b);
        if(a==0&&b==0)
            break;
        else
        {
            they[a]++;
            me[b]++;
        }
    }
    ncount=0;
    for(i=0;i<n;i++)
    {
        if(they[i]==0&&me[i]==n-1)
        {
            printf("%d\n",i);
            ncount++;
        }
    }
    if(ncount==0)
    printf("NOT FOUND");
    getchar();
    getchar();
}
int main()
{
  int n,i,a[20000][2],z=0;
  scanf("%d",&n);
  for(i=0;;i++){
      scanf("%d%d",&a[i][0],&a[i][1]);
      if(a[i][0]==0&&a[i][1]==0)
         break;
  }
  for(int k=0;k<n;k++){
      int c=0;
      for(int j=0;j<i;j++){
          if(k==a[j][0])
             break;
          else if(k==a[j][1])
             c++;
      }
      if(c==n-1)
         printf("%d",k);
      else
         z++; 
   }
   if(z==n)
   printf("NOT FOUND"); 
   return 0;
}
main()
{
	int n,i,j,k,p,a[10001],b[10001],s=0,t=0;
	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<=i-1;j++)
	{
		for(k=0;k<=i-1;k++)
		{
			if(b[j]==b[k])
			s++;
		}
		if(s==n-1)
		{
			for(p=0;p<=i-1;p++)
			{
				if(a[p]==b[j])
				break;
			}
			if(p==i)
			{
				printf("%d",b[j]);
				t=1;
				break;
			}
		}
		s=0;
	}
	if(t==0)
	printf("NOT FOUND");
}
int main()
{
    int n,j,k,count=0,l,i;
    scanf("%d",&n);
    int *a=(int *)malloc(n*n*sizeof(int));
    int *b=(int *)malloc(n*n*sizeof(int));
    for(i=0;i<=n*n-1;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==0&&b[i]==0)
        {
            break;
        }
        count++;
    }
    int *c=(int *)malloc(n*sizeof(int));
    for(l=0;l<=n-1;l++)
    {
        c[l]=1;
    }
    for(j=0;j<=count-1;j++)
    {
        c[b[j]]++;
    }
    for(k=0;k<=n-1;k++)
    {
        if(c[k]==n)
        {
            printf("%d",k);
            break;
        }
    }
    if(k==n)
    {
        printf("Not Found!");
    }
    free(a);
    free(b);
}
void main()
{
	int i,j,n=0,k;
	scanf("%d",&k);
	int rs[10000],brs[10000];
	for(i=0;i<k;i++)
	{
		rs[i]=0;brs[i]=0;
	}
	while(1)
	{
		scanf("%d%d",&i,&j);
		if(i==0&&j==0)break;
		else
		{
			rs[i]++;brs[j]++;
		}
	}
	for(i=0;i<k;i++)
	{
		if(rs[i]==0&&brs[i]==(k-1))
		{
			printf("%d",i);
			n=1;
		}
	}
	if(n==0)
		printf("NOT FOUND");
}
int main()
{
	int i,j,m,n,k; cin>>k;
	int a[k],b[k];
	for (m=0;m<k;m++)
	{a[m]=0; b[m]=0;}
	while (true)
	{
		cin>>i>>j;
		if (i==0&&j==0) break;
		else {a[i]+=1; b[j]+=1;}
	}
	for (n=0;n<k;n++)
		if (a[n]==0&&b[n]==k-1)
			{cout<<n<<endl;break;}
	if (n==k) cout<<"NOT FOUND"<<endl;
	return 0;
}
int main ()
{ 
  int i,j,n,l;
  scanf("%d",&n);  
  int a[n],b[n];
  for (i=0;i<n;i++)
  {a[i]=0;b[i]=0;}
  scanf("%d %d",&i,&j);
  while ((i!=0)||(j!=0))
  { a[i]++;b[j]++;  
    scanf("%d %d",&i,&j);
  } 
  for (i=0;i<n;i++)
  if((a[i]==0)&&(b[i]==n-1))
  {printf("%d\n",i);l=0;}
  if (l==1)
  printf("NOT FOUND"); 

  

}
int main()
{
	int n,a[100000],i,j,b[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
         b[i]=1;
	          a[i]=0;
    }
	while(1)
	{
         scanf("%d %d",&i,&j);
         if(i==0&&j==0) break;
         else
         {
              a[j]++;
              b[i]=0;
         }
    }
    for(i=0;i<n;i++)
    {
         if(b[i]==1)
         {
              if(a[i]==n-1) 
              {
                       printf("%d",i);
                       break;
              }
         }
    }
    if(i==n) printf("NOT FOUND");               
}
main()
{
      int i,j,k,n,m=0,l=0,p=0,q=0;
      int a[100000][2];
      scanf("%d",&n);
      scanf("%d %d",&a[0][0],&a[0][1]);
      while (a[m][0]>0||a[m][1]>0)                    //??m? 
      {
            scanf("%d %d",&a[m+1][0],&a[m+1][1]);
            m++;
      }
      for (i=0;i<n;i++)
      {
          l=0; 
          for (j=0;j<m;j++)                           //??????i 
          {
              if (a[j][1]==i)
              l++;
          }
          if (l==n-1)
          {
                     p=0;
                     for (j=0;j<m;j++)               //i?????? 
                     {
                         if (a[j][0]==i)
                         p++;
                     }
                     if (p==0)
                     {
                              printf ("%d\n",i);
                              q++;
                     }
          }
      }
      if (q==0)
      printf("NOT FOUND\n");
      getchar();
      getchar();
}
main()
{
	int n,a[100000]={0},i,temp1,temp2,p=0;
	scanf("%d",&n);
	for(i=0;;i++)
	{
		scanf("%d%d",&temp1,&temp2);
		if(temp1==0&&temp2==0)
		{
			break;
		}
		else
		{
			a[temp1]=0;
			a[temp2]++;
		}
	}
	for(i=0;i<=n-1;i++)
	{
		if(a[i]==n-1)
		{
			p++;
			printf("%d\n",i);
		}
	}
	if(p==0)
	{
		printf("NOT FOUND\n");
	}
	return 0;
}
int main()
{
	int n;
	int a[10001],b[10001],c[100000],d[100000];
	scanf("%d",&n);
	int i,j,k,sum=0,cs=0;
	for(i=0;i<10001;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		cs=cs+1;
		if(a[i]==0&&b[i]==0)
			break;
	}
	for(i=0;i<n;i++)
	{
		sum=0;
		for(j=0;j<cs;j++)
		{
			if(i==a[j])
			{
				sum=sum+1;
			}

		}
		c[i]=sum;
	}
	 for(i=0;i<n;i++)
	{
		if(c[i]==0)
		{
			printf("%d",i);
			sum+=1;
		}

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

}
main()
{
      int n,i,j,w,x,y,v;
      scanf("%d",&n);
      v=n*n;
      int a[100000],b[100000]; 
      for (i=0;i<100000;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
          if(a[i]==0 && b[i]==0)
          {
                     w=i+1;
                     break;
          }
      }
      for (j=0;j<n;j++)
      {
          x=0;
          y=0;
          for(i=0;i<w;i++)
          {
                    if(a[i]==j)
                    x++;
                    if(b[i]==j)
                    y++;
          }
          if(j==0)
          {
                  if(x==1 && y==n)
                  {
                               printf("%d",j);
                               break;
                  }
                  
          }
          else
          {
              if(x==0 && y==n-1)
             {
                  printf("%d",j);
                  break;
             }    
          }
      }
      if(j==n)
      printf("NOT FOUND");
      getchar();
      getchar();
}
int main()
{
	int n, i, j, flag = 0, num = 0;
	int a[100000], b[100000], sum1[10000] = {0}, sum2[10000] = {0};
	cin>>n;
	for (i = 0; ; i++)
	{
		cin>>a[i]>>b[i];
		num++;
		if (a[i] == 0 && b[i] == 0)
			break;
	}
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < num - 1; i++)
		{
			if (a[i] == j)
				sum1[j]++;
			if (b[i] == j)
				sum2[j]++;
		}
	}
	for (j = 0; j < n; j++)
	{
		if (sum1[j] == 0 && sum2[j] == n - 1)
		{
			cout<<j<<endl;
			flag = 1;
		}
	}
	if (flag == 0)
		cout<<"NOT FOUND"<<endl;
	return 0;
}
int main()
{
     int i,j,a[100000],b[100000],s,c[100000],n;
     scanf("%d",&n);
     
     
    for (i=0;i<n;i++) c[i]=0;
     
    
     
     scanf("%d %d",&a[0],&b[0]);
     for (i=1;;i++)
     {c[b[i-1]]=c[b[i-1]]+1;
         scanf("%d %d",&a[i],&b[i]);
    if (a[i]+b[i]==0)break;
    
    
    }
         s=0;
         for (j=0;j<n;j++)
        if  (c[j]==n-1)
        {printf("%d",j);
          s=1;}
          if(s==0) printf("NOT FOUND");
          
     
          }
int main()
{
	int n = 0, a = 0, b = 0, i = 0, pos = 0, count[10000], num = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i ++)
		count[i] = 0;
	
	while (scanf("%d%d", &a, &b) && (a + b != 0))
		count[b] ++;

	for (i = 0; i < n; i ++)
	{
		if (count[i] == n -1)
		{
			pos = i;
			num ++;
		}
	}

	if (num == 1)    printf("%d\n", pos);
	else    printf("NOT FOUND\n");

	return 0;
}
main()
{
      int n,i,j,w,x,y;
      scanf("%d",&n);
      int a[100000],b[100000]; 
      for (i=0;i<100000;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
          if(a[i]==0 && b[i]==0)
          {
                     w=i+1;
                     break;
          }
      }
      for (j=0;j<n;j++)
      {
          x=0;
          y=0;
          for(i=0;i<w;i++)
          {
                    if(a[i]==j)
                    x++;
                    if(b[i]==j)
                    y++;
          }
          if(j==0)
          {
                  if(x==1 && y==n)
                  {
                               printf("%d",j);
                               break;
                  }
                  
          }
          else
          {
              if(x==0 && y==n-1)
             {
                  printf("%d",j);
                  break;
             }    
          }
      }
      if(j==n)
      printf("NOT FOUND");
      getchar();
      getchar();
}
int main()
{
    int meet[100000];
    int i, j, n, a, b;

    scanf( "%d", &n );
    memset( meet, 0, n * sizeof(int) );
    for( scanf("%d%d",&a,&b); a + b; scanf("%d%d",&a,&b) )
        meet[b]++;

    for( i = 0; i < n; i++ )
        if( meet[i] == n -1 )
            break;

    if( i == n )
        printf( "NOT FOUND" );
    else printf( "%d\n", i );

    return 0;
}
/*???:????
**???:??
**?  ?:2010?12?11?
*/
int main()
{
	int i, j, n, flag = 0;
	int know[10000] = {0}, count[10000] = {0};//???????
	cin >> n;
	while (cin >> i >> j)
	{
		if (i == 0 && j == 0)
			break;
		know[i]++;//i????,+1
		count[j]++;//j???,+1
	}
	for (i = 0; i < n; i++)
		if (know[i] == 0 && count[i] == n - 1)//????i??i???????,????????
		{
			cout << i << endl;
			flag = 1;//??
		}
	if (flag == 0)
		cout << "NOT FOUND" << endl;//????????
	return 0;
}
int main ()
{   int n,i,x,y,t=0;
    int num[10000];
    for(i=0;i<1000;i++)
     num[i]=0;
    scanf("%d",&n);
    for(i=0;;i++)
   {  scanf("%d %d",&x,&y);
      if(x==0&&y==0) break;
      num[x]++;
      num[y]++;
    }
    for(i=0;i<n;i++)
     if(num[i]==n-1) { t=1;break;}
     if(t==0) printf("NOT FOUND");
     else printf("%d",i);
   return 0;
}
//*********************************************
//*?????????                        **
//*?????? 1100012914                   **
//*???2011.12.9                           **
//*********************************************


int main()
{
	int n, i, a, b, fam1[100000] = {0}, fam2[100000] = {0}, flag = 0, *p1, *p2;

	cin >> n;
	cin >> a >> b;
	while (!(a == 0 && b == 0))
	{
		fam1[a] = 1;
		fam2[b]++;
		cin >> a >> b;
	}
	p1 = fam1;
	p2 = fam2;
	for (i = 0; i < n; i++)
	{
		if (*(p1 + i) == 0 && *(p2 + i) == n - 1)
		{
			flag++;
			cout << i;
		}
	}
	if (flag == 0)
		cout << "NOT FOUND";
		return 0;
}
int main()
{
	int n;int a[100000];int b[100000];
	cin>>n;
	for(int t=0;t<n;t++)
	{
		a[t]=0;
		b[t]=0;
	}
	int i,j;
	while(cin>>i)
	{
		cin>>j;
		if(i==0&&j==0)
			break;
		else
		{
			a[i]++;
			b[j]++;
		}
	}
	for(int r=0;r<n;r++)
	{
		if(a[r]==0&&b[r]==n-1)
		{
			cout<<r<<endl;
		}
	}
	return 0;
}
int to[10005],from[10005];
int n;
int main(){
	int k1,k2,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		to[i]=0;
		from[i]=0;
	}
	while (true) {
		scanf("%d %d",&k1,&k2);
		if (k1==0&&k2==0) break; 
		to[k2]++;
		from[k1]++;
	}
	int t=-1;
	for (i=0;i<n;i++) {
		if (to[i]==n-1&&from[i]==0) {
			printf("%d\n",i);
			t=i;
		}
	}
	if (t<0) printf("NOT FOUND\n");
	return 0;
}
main()
{
    int n;
    int s=0;
    scanf("%d",&n);
    int X[n];
    for(int h=0;h<n;h++)
    {
            X[h]=h;
            }
             int i,j;
     for(;i!=0||j!=0;)
     {
            
             scanf("%d %d",&i,&j);
             X[j]=X[j]+1;
     }
     for(int t=0;t<n;t++)
     {
             if((X[t]-t)>=(n-1)) 
             {
                printf("%d",t);
                s++;
                }
       }
       if(s==0) printf("NOT FOUND");
    
     }
int main()
{
    int n,i,j,p,q;
    j=-1;
    scanf("%d",&n);
    int a[10000];
    for(i=0;i<10000;i++)
    {
        a[i]=0;
    }
    do
    {
        scanf("%d %d",&p,&q);
        if(p==0&&q==0)
        {
            break;
        }
        a[p]=a[p]-1;
        a[q]=a[q]+1;
    }
    while(p!=0||q!=0);
    for(i=0;i<n;i++)
    {
        if(a[i]==n-1)
        {
            printf("%d",i);
            j=i;
        }
    }
    if(j==-1)
    {
        printf("NOT FOUND");
    }
    return 0;
}
//*****************************************
//*   ????                            *
//*   ??????                        *
//*   ?????2011?12?12?            *
//*****************************************


int main()
{
	int n, i, *p, *q, num, flag, sum, a[500000], b[500000];
	cin >> n;
	num = 0;
	flag = 0;
	sum = 0;
	for(i = 0; ; i ++)
	{
		cin >> a[i] >> b[i];
		num ++;
		if(a[i] == 0 && b[i] == 0)
			break;
	}
	for(i = 0; i < n; i ++)
	{
		q = b;
		for(p = a; p <= a + num - 1; p ++)
		{
			if(*p == i)
				break;
			else
			{
				if(*q == i)
					sum = sum + *p;
				q ++;
			}
		}
		if(sum == n * (n - 1) / 2 - i)
		{
			flag = 1;
			cout << i;
			break;
		}
		sum = 0;
	}
	if(flag == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
main()
{
	int a[10000],b[10000],c[10000]={0},d[10000]={0};
	int i,n;
	scanf ("%d",&n);
	for (i=0;i<10000;i++)
	{
		scanf ("%d %d",&a[i],&b[i]);
		if (a[i]==0&&b[i]==0)break;
		c[a[i]]++;
		d[b[i]]++;
	}
	for (i=0;i<n;i++)
	{
	if (d[b[i]]==n-1&&c[b[i]]==0)
	{
	printf ("%d",b[i]);
	break;
	}
	}
	if (i==n)
	printf ("NOT FOUND");
}
/*
 * shehuimingliu.cpp
 *
 *  Created on: 2011-1-8
 *      Author: lz
 */

int people[20000][20000];
int main()
{
	int n;
	cin>>n;
	int a;
	int b;

	int i;
	int j;
	cin>>a>>b;
	while(a!=0||b!=0)
	{
		people[a][b]=1;
		cin>>a>>b;
	}
	for(j=0;j<n;j++)
	{
		for(i=0;i<n;i++)
		{
			if(i!=j)
			    if(people[i][j]==1&&people[j][i]==0)
				    continue;
			    else
				    break;
		}
		if(i==n)
		{
			cout<<j;
			break;
		}
	}
	if(j==n)
	{
		cout<<"NOT FOUND";
	}
	return 0;
}
int main(){
	int i,j,n,in[MAXN]={0},ou[MAXN]={0};
	for (scanf("%d%d%d",&n,&i,&j);i+j>0;scanf("%d%d",&i,&j)){
		in[i]++;
		ou[j]++;
	}
	for (i=0;i<n;i++)
		if (in[i]==0&&ou[i]==n-1){ printf("%d\n",i);return 0;}
		printf("NOT FOUND\n");
	return 0;

	
}
int main()
{
	int i,m,j,n,flag=0;
	int *p,*q;
    scanf("%d",&n);
    p=(int*)malloc(sizeof(int)*(n+1));
    q=(int*)malloc(sizeof(int)*(n+1));
    memset(p,0,sizeof(p));
    memset(q,0,sizeof(q));
    for(;;){
    scanf("%d%d",&i,&j);
        if(i==0&&j==0){
        	break;
        }
        else{        	
    	p[i]=1;
    	q[j]++;
        }
    }
    for(i=0;i<n;i++){
   	   if(p[i]==0&&q[i]==n-1){
	   printf("%d\n",i);
	   flag=1;   	   	
   	   }	
    }  
	if(flag==0)
     printf("NOT FOUND");    
}
//******************************************************
//* ?????????
//* ????? 1200012858
//* ???2012-12-15
//******************************************************

struct people
{
	int p;
	int q;
	int f;
}pp[100000];

int main()
{
	int n, i = 0, count = 0;
	int num[10000] = {0};
	cin >> n;
    do
	{
		i++;
		cin >> pp[i].p >> pp[i].q;
		pp[i].f = 1;
		count++;         // count ?????????
	}while(pp[i].p != 0 || pp[i].q != 0);
	count--;
	for (i = 0; i < n; i++)
	{
		for (int j = 1; j <= count; j++)
		{
			if (pp[j].q == i)
				num[i]++;
		}
		if (num[i] == n - 1)
			cout << i << endl;
	}
	return 0;
}
int main ()
{
	int n, know[10000] = {0}, known[10000] = {0},
	    flag, man, man0;
	cin >> n;
	do
	{
		cin >> man >> man0;
		if (man == 0 && man0 == 0) break;
		++know[man];
		++known[man0];
	} while(1);
	flag = 0;
	for (int i = 0; i < n; i++)
		if (know[i] == 0 && known != 0)
		{
			cout << i << endl;
			++flag;
		}
	if (flag == 0)
		cout << "NOT FOUND" << endl;
	getchar();
	getchar();
	return 0;
}
int main()
{
	struct person
	{
		int rs;
		int brs;
	}p[10000];

	int n;
	int i,j,k,l,m,q;
	cin>>n;
	int t1=0,t2=1;
	for(i=0;t1!=t2;i++)
	{
		cin>>t1>>t2;
		p[i].rs=t1;
		p[i].brs=t2;
	}


	
	int flag,out=0;
	int record[10000];
	for(j=0;j<=n-1;j++)
	{
		flag=1;
		for(k=0;k<=i-2;k++)
		{
			if(p[k].rs==j)
			{
				flag=0;
				break;
			}
		}
		if(flag==0)
			continue;
		for(q=0;q<=n-1;q++)
		{
			record[q]=0;
		}
		for(l=0;l<=i-2;l++)
		{
			if(p[l].brs==j)
			{
				record[p[l].rs]=1;
			}
		}
		
		for(m=0;m<=n-1;m++)
		{
			if(m==j)
				break;
			if(record[m]==0)
			{
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
			cout<<j<<endl;
			out=1;
		}
	}
	if(out==0)
		cout<<"NOT FOUND"<<endl;
		

	return 0;
}
//* * * * * * * * * * * * * * * * * * * * * * * * 
//*??????????                         *
//*??????????.cpp                     *
//*?????  1000012839                       *
//*???2010.12.10                             *
//* * * * * * * * * * * * * * * * * * * * * * * * 


int main()
{
	int n;
	int celebrity[10000] = {0};
	int a[90000][2];
	int i, j, k, flag, count;

	cin >> n;
	for (i = 0; i < n; i++)
		celebrity[i] = 1;
	i = 0;
	while (1)
	{
		cin >> a[i][0] >> a[i][1];
		if (a[i][0] == 0 && a[i][1] == 0)
			break;
		else
			i++;
	} 
	flag = 0;
	for (k = 0; k < n; k++)
	{
		for (j = 0; j <= i - 1; j++)
		{
			if (a[j][0] == k)
				celebrity[k] = 0;
		}
	}
	for (k = 0; k < n; k++)
	{
		if (celebrity[k] == 1)
		{
			count = 0;
			for (j = 0; j <= i - 1; j++)
				if (a[j][1] == k)
					count++;
			if (count == n - 1)
			{
				flag = 1;
				cout << k << endl;
			}
		}
	}
	if (!flag)
		cout << "NOT FOUND" << endl;
	return 0;
}
main()
{
int n,i,j;
scanf("%d",&n);
int a[n+5],b[n+5];
for (i=0;i<n;i++) {a[i]=0; b[i]=0;}
while (1)
{
scanf("%d %d",&i,&j);
if (i==j&&i==0) break;
a[i]++;
b[j]++;
}
int flag=0;
for (i=0;i<n;i++)
if (a[i]==0&&b[i]==n-1)
{
flag=1;
printf("%d\n",i);
}
if (!flag) printf("NOT FOUND\n");
}
int main()
{         
          int h,v,j,z,i,n,p,q,u;
          int a[100000],b[100000],c[10000]={0};
          scanf("%d",&n);
          for( i=0;;i++)
          {
                  scanf("%d %d",&p,&q);
                  a[i]=p;b[i]=q;
                  if(p==0&&q==0){v=i;break;}
          }
               for(j=0;j<=v-1;j++)
               {
                   c[a[j]]--;
                   c[b[j]]++;
               }
               for(j=0;j<=n-1;j++)
               {
                                  
                 if(c[j]==n-1){u=1;h=j;}
               }
               if(u==1)printf("%d",h);
               else printf("NOT FOUND");
    
}
main()
{
      int a[20000],b[20000],c[20000]={0},d[20000]={0},t=0,i,n;
      scanf("%d",&n);
      for(i=0;;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
          if(a[i]==0&&b[i]==0)
             break;
      }
      for(i=0;;i++)
      {
           if(a[i]==0&&b[i]==0)
           break;
           else
           {
           c[a[i]]++;
           d[b[i]]++;
           }
      }
      for(i=0;i<n;i++)
      {
          if(c[i]==0&&d[i]==n-1)
           {
                 printf("%d",i);
                 t++;
           }
      }
      if(t==0)
      printf("NOT FOUND\n");
      getchar();
      getchar();
}
main()
{
  int i,n,x,y,t=0;
  int a[10000],b[10000];
  scanf("%d",&n);
  while(scanf("%d %d",&x,&y)==2)
  {
    if(x==0&&y==0)
      break;
    else
      a[x]++;
      b[y]++;
      }
  for(i=0;i<n;i++)
  {
    if (a[i]==0&&b[i]==n-1)
      printf("%d",i);
      t++;
      }
  if(t==0)
    printf("NOT FOUND");
  getchar();
  getchar();
  getchar();
  return 0;
}
int main()
{
    int n;
    scanf("%d",&n); 
    int i,j;
    int f[10000];
    for(i=0;i<n;i++)   f[i]=0;
    while(!(i==0&&j==0))   
    { 
       scanf("%d %d",&i,&j);f[i]--;f[j]++;}
   for(i=0;i<n;i++) 
    if(f[i]==n-1) { printf("%d",i); break;}  
   if(i==n)    printf("NOT FOUND");
return 0;
}
main()
{
      int n,i,k,l;
      int m[99999][2];  //??????????? ????????9999999???? 
      scanf("%d",&n);
      for(i=0;;i++)
      {
                   scanf("%d %d",&m[i][0],&m[i][1]);  //?????????????? 
                   if (m[i][0]+m[i][1]==0)
                   break;
      }
      for(k=0;k<n;k++)
      {    
           int p=0,q=0;
           for(l=0;l<=i-1;l++)
           {
                         if(k==m[l][1])
                         p++;
           }
           for(l=0;l<=i-1;l++)
           {
                         if(k==m[l][0])
                         break;
                         else
                         q++;
           }
           if(p==n-1&&q==i) 
           {
                            printf("%d",k);
                            goto end;
           }
      }     
      end:
      if(k==n)
      printf("NOT FOUND"); 
}
int main()
{
	int n,i;
	cin>>n;
	int a[100000][2];
	memset(a,0,sizeof(a));
	int *p=&a[0][0];
	int b[n];
	memset(b,0,sizeof(b));
	for(i=0;;i++)
	{
		cin>>*p>>*(p+1);
		p+=2;
		if(*(p-2)==0&&*(p-1)==0)
		break;
	}
	int c=i-1;
	for(i-1;i>=0;i--)
	{
		b[a[i][1]]++;
	}
	int j;int flag=1,fg=1;
	for(i=0;i<=n;i++)
	{
		if(b[i]==n-1)
		{
			for(j=0;j<c;j++)
			{
				if(a[j][0]==i)
				break;
			}
			if(j==c)
			{cout<<i<<endl;fg=0;}
			else
			if(flag)
			{
				cout<<"NOT FOUND"<<endl;
				flag=0;
			}
		}
	}
                  if(fg)
		{
			cout<<"NOT FOUND"<<endl;
			
		}

	return 0;
}
int main()
{
	int n = 0;
	int num1[100000];
	int num2[100000];
	int flag[100000];
	int except[100000];
	int i = 0;
	int j = 0;
	int p = 0;
	int sum = 0;
	int f = 0;

	memset(num1,0,sizeof(num1));
	memset(num2,0,sizeof(num2));
	memset(flag,0,sizeof(flag));
	memset(except,0,sizeof(except));

	cin >> n;
	while (1)
	{
		cin >> num1[i] >> num2[i];
		except[num1[i]]++;
		if ((num1[i] == 0) && (num2[i] == 0))
			break;
		i++;
	}

	for (j = 0; j < n; j++)
	{
		if (except[j] != 0)
			continue;
		sum = 0;
		memset(flag,0,sizeof(flag));
		for (p = 0; p < i; p++)
		{
			if (num2[p] == j)
				if (flag[num1[p]] == 0)
					flag[num1[p]]++;
			if (num1[p] == j)
				flag[num1[p]] = -1;
		}
		for (p = 0; p < n; p++)
			sum += flag[p];
		if (sum == n - 1)
		{
			cout << j;
			f = 1;
		}
	}
	if (f == 0)
		cout << "NOT FOUND";

	return 0;
}
main()
{
      int n;
      scanf("%d",&n);
      int m=0;
      int b1[100000],c1[100000];
      int b2[n],c2[n];
      int i;
      for(i=0;i<100000;i++)
      {
                     scanf("%d %d",&b1[i],&c1[i]);
                     m++;
                     if(b1[i]==0&&(c1[i]==0))
                     break;
                     
      }
      int d,e;
      for(d=0;d<n;d++)
      {
                       b2[d]=0;
                       for(e=0;e<m-1;e++)
                       {
                                       if(d==b1[e])
                                       b2[d]++;
                       }
      }
      int f,g;
      for(f=0;f<n;f++)
      {
                       c2[f]=0;
                       for(g=0;g<m-1;g++)
                       {
                                       if(f==c1[g])
                                       c2[f]++;
                       }
      }
      int h;
      int count=0;
      for(h=0;h<n;h++)
      {
                       if((b2[h]==0)&&(c2[h]==n-1))
                       {
                                                   printf("%d\n",h);
                       }
                       if((b2[h]!=0)||(c2[h]!=n-1))
                       {
                                                   count++;
                       }
      }
      if(count==n)
      printf("NOT FOUND");
}
int main()
{
    int n,a[10000],r[10000],k,i,c=1,b=1,frag=0;
    scanf("%d",&n);
    k=n;
    for(i=0;i<n;i++)a[i]=1,r[i]=0;
    for(;;)
    {
      scanf("%d %d",&b,&c);
      if(c+b>0)
         {
               r[c]++;
               if(a[b]==1)k--,a[b]=0;
         }
      else break;
      if(k==0)break;
    }
    if(k==1)
      for(i=0;i<n;i++)
        if(a[i]==1)
          if(r[i]==n-1){printf("%d",i);frag=1;break;}
    if(frag==0)printf("NOT FOUND");
   
}
main()
{
      int n,i,I,j=1,k=0;
      scanf("%d",&n);
      int a[n],b,c,t[n];
      for(i=0;i<n;i++)
      {
              a[i]=i;
              t[i]=0;
      }
      while(j==1)
      {
                 scanf("%d %d",&b,&c);
                 if(b==0&&c==0)
                 break;
                 else
                 for(i=0;i<n;i++)
                 {
                                 if(c==a[i])
                                 t[i]++;              
                 }
      }
      for(i=0;i<n;i++)
      {
        if(t[i]==n-1)
        {
          I=i;
          k++;
        }
      }
      if(k==0)
      printf("NOT FOUND");
      else
      printf("%d",I);
            }