semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int n;
    int a,b;
    int i,j,k,l;
    int s;
    scanf("%d",&n);
    int *p=(int*)malloc(n*n*sizeof(int));
    int *q=(int*)malloc(n*n*sizeof(int));
    for(l=0;l<n*n;l++)
    {
        p[l]=0;
        q[l]=0;
    }

    for (k=0;k<n*n;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(j=0;j<n;j++)
        {
            if(p[j]==0&&q[j]==(n-1))
            {
                s=0;
                s++;
                printf("%d\n",j);
            }
        }
    if(s==0)
    {
        printf("NOT FOUND");
    }

    free(p);
    free(q);
    return 0;
}
main()
{
   int N,i,A,B;
   int a[1000000],b[1000000];
   scanf("%d",&N);                     //???
   int c[N];
   for(i=0;i<N;i++)
   {c[i]=N;}
   i=0;
   while(scanf("%d %d",&A,&B)&&((A*A+B*B)!=0)) 
   {  
      c[A]=0;             
      a[i]=A;
      b[i]=B;             
      i++;}   
   
   for(i;i>0;i--)
   {
    c[b[i-1]]--;           
                  }
    int k=0;
    for(i=0;i<N;i++)
    {
    if(c[i]==1)
    printf("%d",i);
     else
     k++;            
        }              
    if(k==N)
    printf("NOT FOUND") ;
    
    
    getchar();      
    getchar();      
    getchar(); 
    getchar(); 
    getchar();      
    getchar();      
    getchar();
    getchar();      
    getchar(); 
    getchar(); 
    getchar();           
   }
main()
{
      int i,n,a,b,c,s[10000],d[10000];
      scanf("%d",&n);
      for(i=0;i<n;i++)
        {
          s[i]=0;
          d[i]=0;
        }
        a=1;
        b=1;
      while((a+b)!=0)
      {
        scanf("%d %d",&a,&b);
        s[b]=s[b]+a;
        if(a==0)
        d[b]=1;
      }
      
      c=0;
      if(s[0]==n*(n-1)/2)
        {
          printf("0\n");
          c=1;
        }
      for(i=1;i<n;i++)
      {
        if(((s[i]+i)==n*(n-1)/2)&&d[i]==1)
        {
          printf("%d\n",i);
          c=1;
        }
      }
      if(c==0)
        printf("NOT FOUND");
}
int main()
{
     int a[100000],b[100000],c[100000]={0},n,i,j,k,s=0;
     scanf("%d",&n);
     for(i=0;;i++)
     {
           scanf("%d",&a[i]);
           scanf("%d",&b[i]);
           if (a[i]==0&&b[i]==0)
           break;
     }
     for(j=0;j<i;j++)
     c[b[j]]=c[b[j]]+1;
     for(k=0;k<n;k++)
     if (c[k]==n-1)
     {
        s++;
        printf("%d",k);
     }
     if(s==0)
     printf("NOT FOUND");
}
//???2010?12?8?

//???1000010586_???

//?????????

int pan( int a[] , int );
int main()
{
	int n , i , j;
	int a[ 10000 ] = {0};
	cin >> n;
	while ( cin >> i >> j )
	{
		if ( i == 0 && j == 0 )
			break;
		a[ j ]++;
	}
	if ( pan( a , n ) != -1 )
		cout << pan( a  , n ) << endl;
	else if ( pan( a , n ) == -1 )
		cout << "NOT FOUND" << endl;
	return 0;
}
int pan( int a[] , int n )
{
	int i;
	for ( i = 0 ; i <= n - 1 ; i++ )
	{
		if ( a[ i ] == n - 1 )
		{
			return i;
			break;
		}
	}
	if ( i == n )
		return -1;
}
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!");
    }
}
int main ()
{
	int renren[100000][2], n, i = 0, j, qun[100000] = {0}, ming[100000] = {0}, flag = 1;
	cin >> n;
	do 
	{
		for (j = 0; j < 2; j ++)
		{
			cin >> renren[i][j];
		}
		i ++;
	}while (renren[i-1][0] != 0 || renren[i-1][1] != 0 );

	for (j = 0; j < i - 1; j ++)
	{
		qun[renren[j][0]] ++;
		ming[renren[j][1]] ++;
	}

	for (j = 0; j < i - 1; j ++)
		if (qun[j] == 0 && ming[j] == n - 1)
		{
			cout << j;
			flag = 0;
		}
	if (j == i - 1 && flag == 1)
			cout << "NOT FOUND";
		return 0;
}
main()
{
      int n,i,c=0,k,j,d,e;
      scanf("%d",&n);
      int a[100000],b[100000];
      for (i=0;i<1000000;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
          if (a[i]==0&&b[i]==0)
          break;
      }
      k=i-1;
      for (i=0;i<=n-1;i++)
      {
          d=0;
          e=0;
          for (j=0;j<=k;j++)
          {
              if (b[j]==i)
              d++;
          }
          for (j=0;j<=k;j++)
          {
              if (a[j]==i)
              e++;
          }
          if ((d==n-1)&&(e==0))
          {
                  printf("%d\n",i);
                  c++;
          }
      }
      if (c==0)
      printf("NOT FOUND\n");
}
/**
* @file homework.cpp
* @author ??
* @date 2010?11?09
* @description 
* ??????:??????  
*/
int a[9000][9000] = {0};                    //??????A??B
int main()
{
	int i, j, n, g, flag = 0;
	cin >> n;
	cin >> i >> j;
	while (i != 0 || j!=0)
	{
		a[i][j] = 1;
		cin >> i >> j;                     //????
	}
	for (j=0;j<n;j++)
	{
		g = 0;
		for(i=0;i<n;i++)
		{
		
			if (i > 1 && g == 0)
				break;
			if (a[i][j] == 1)
				g++;
		}
		if (g == n-1)                   //????
		{
			cout << j;
			flag = 1;
			break;
		}
	}
	if (flag == 0)                     //??????
		cout << "NOT FOUND";
	return 0;
}
int main()
{
int n,i,j,k=1,c,d;
int **a;
int *p,*q;
scanf("%d",&n);
p=(int*)malloc(n*sizeof(int));
q=(int*)malloc(n*sizeof(int));
a=(int**)malloc(n*sizeof(int*));
for(i=0;i<n;i++)
	{
	a[i]=(int*)malloc(n*sizeof(int));
	p[i]=0;
	q[i]=0;
	}
while(k==1)
	{
		scanf("%d",&c);
		scanf("%d",&d);
		if(c==0&&d==0)
			break;
		if(a[c][d]!=1)
		{	
			p[c]=1;
			q[d]++;
			a[c][d]=1;
		}
	}
for(i=0;i<n;i++)
{
	if(p[i]==0&&q[i]==n-1)
		{
			printf("%d",i);
			return(0);
		}
}
printf("NOT FOUND");
return(0);
}
int know[10000];
int main()
{
	memset(know, 0, sizeof(know));  //?????????????????????????n - 1??????????
	int n;
	cin >> n;
	int flag = 1;
	int i, j;
	for (;;)
	{
		cin >> i >> j;
		if (i == 0 && j == 0)
		{
			break;
		}
		else
		{
			know[i] = -1;
			know[j]++;
		}
	}
	for (int k = 0; k < n; k++)
	{
		if (know[k] == n - 1)
		{
			cout << k << endl;
			flag = 0;
			break;
		}
	}
	if (flag)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
    int n,m,l,k,i;
    scanf("%d",&n);
    int a[100000],b[100000],c[n],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<n;i++)
    {
         c[i]=0;
         d[i]=0;
         
      }
      k=0;
       for(i=0;;i++)
    {    
      if(a[i]==0&&b[i]==0)
                 break;
                 else
                     { m=a[i];
        c[m]=1;
        l=b[i];
        d[l]++;}
        
                
      }
          for(i=0;i<n;i++)
    {
           if(c[i]==0&&d[i]==n-1)
           printf("%d",i);
           k=1;
      }
      if(k==0)
       printf("NOT FOUND");
      
      
      

    getchar();
    getchar();
    getchar();
    getchar();
    getchar();
    

}
int main()
{
	int n, i, p, q, j,k,  person[10000], flag = 0;
	cin >> n;
	for (j = 0; j < 10000; j++)
	{
		person[j] = 0;
	}
	while ((cin >> p) && (cin >> q))
	{
		if ((p == 0) && (q == 0))
		{
			break;
		}
		else
		{
			person[p]--;      // ???p???????????????-1
		    person[q]++;     // p?????????q?????????
		} 
	}
	for (k = 0; k < n; k++)
	{
		if (person[k] == n - 1)
		{
			flag = 1;
			cout << k << endl;
		}
	}
	if (!flag)
	{
		cout << "NOT FOUND";
	}
	return 0;
}
// ******************************
// *** ??????.cpp       ***
// *** ID:1000012895          ***
// *** ???                 ***
// *** 2010/12/11             ***
// ******************************
int main()
{
	int know[11101], cnt = 0;
	int n, i, p1, p2;
	cin >> n;
	for(i = 0; i < n; i++)
			know[i] = 0;
	while(true)
	{
		cin >> p1 >> p2;
		if(p1 == 0 && p2 == 0)
			break;
		know[p2]++;
		know[p1] = -1;
	}
	for(i = 0; i < n; i++)
		if(know[i] == n - 1)
		{
			cout << i;
			cnt++;
		}
	if(cnt == 0)
		cout << "NOT FOUND";
	return 0;
}
int main ()
{
    int p[50000];
    int n,i,t,x,y;
    scanf("%d",&n);

    for(i=0;i<n;i++)
        p[i]=0;
    scanf("%d %d",&x,&y);
    while(x!=0||y!=0)
    {
        if (x!=y)
        {p[x]--;
        p[y]++;}
        scanf("%d %d",&x,&y);
    }
    t=1;
    for(i=0;i<n;i++) if(p[i]==n-1)
    {
        printf("%d",i);
        t=0;
        break;
    }
    if (t) printf("NOT FOUND");
}
main()
{
      int a[20001],b[20001],i,j,k,n;
      scanf("%d",&n);
      scanf("%d",&k);
      scanf("%d",&j);
      for(i=0;i<=n;i++)
      {
                       a[i]=0;
                       b[i]=0;
                       }
      while(k>0||j>0)
      {
           a[k]++;
           b[j]++;
           scanf("%d",&k);
           scanf("%d",&j);
           }
      j=0;     
      for(i=0;i<=n-1;i++)
         if(a[i]==0&&b[i]>0)
         { 
          k=i;
          j=1;
          }
      if(j) printf("%d\n",k);
      else printf("NOT FOUND\n");
      }
int a[100001],b[100001],c[100001],x,y,p;
int main()
{
	int n,i;
	cin>>n;
	cin>>x>>y;
	while(x!=0||y!=0)
	{
		b[y]++;
		c[x]=1;
		cin>>x>>y;
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==n-1&&c[i]==0)  
		{
			cout<<i<<endl;
			p=1;
		}
	}
	if(p==0)  cout<<"NOT FOUND"<<endl;
	return 0;
}
int main()
{
	int n,m,a[10000][2],i,j,c,d[10000]={0},b=0;
	scanf("%d",&n);
	for(i=0;1;i++)
	{
		for(j=0;j<2;j++)
		{
			scanf("%d",&a[i][j]);
		}
		if(a[i][0]==0&&a[i][1]==0)
		{
			m=i;
			break;
		}
	}
	for(i=0;i<m;i++)
	{
		d[a[i][1]]++;
	}
	for(i=0;i<m;i++)
	{
		if(d[i]>=(n-1))
		{
			c=i;
			b=1;
		}
	}
	for(i=0;i<m;i++)
	{
		if(a[i][0]==c&&a[i][1]!=c)
			b=0;

	}
	if(b==0)
		printf("NOT FOUND");
	if(b==1)
		printf("%d",c);
	

	
return 0;
}
int main()
{
    int n,m;
    int q=0;
    scanf("%d",&n);
    int i=0,j,t=0;
    int a[100000];
    int b[100000];
    for(i=0;;i++)
    {
                     scanf("%d %d",&a[i],&b[i]);
                     if(a[i]==0&&b[i]==0)
                     break;
    }
    m=i;
    for(i=0;i<n;i++)
    {               int f=0;
                    for(j=0;j<m;j++)
                    {
                       if(i==a[j])
                      { f=1;
                       break;}             
                    }
                    if(f==0)  
                 {
                    int p=0;
                    for(j=0;j<m;j++)
                    {
                                    if(i==b[j])
                                    p++;
                    }
                    if(p==n-1)
                    {
                            printf("%d\n",i);
                            q=1;
                    }
                 }
    }
    if(q==0)
    printf("NOT FOUND");
    getchar();
    getchar();
}
main()
{
      int n;
      scanf("%d",&n);
      int a[100000],b[100000];
      int i;
      int count=0;
      for (i=0;i<10000000;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
          if (a[i]==0&&b[i]==0)
          {
                               break;
          }
      }
      int k,j;
      k=i-1;
      int count1,count2;
      for (i=0;i<=n-1;i++)
      {
          count1=0;
          count2=0;
          for (j=0;j<=k;j++)
          {
              if (b[j]==i)
              {
                          count1++;
              }
          }
          for (j=0;j<=k;j++)
          {
              if (a[j]==i)
              {
                          count2++;
              }
          }
          if ((count1==n-1)&&(count2==0))
          {
                                     printf("%d\n",i);
                                     count++;
          }
      }
      if (count==0)
      {
                   printf("NOT FOUND\n");
      }
}
main()
{
      int n,i,j;
      scanf("%d",&n);
      int *p=(int *)malloc(n*sizeof(int));
      for(i=0;i<n;i++)
      {
                      p[i]=0;
                      }
      for(;;)
      {
             scanf("%d %d",&i,&j);
             if(i==0&&j==0) break;
             else
             {
                 p[j]++;
                 p[i]=-n;
                 }
      }
      for(i=0;i<n;i++)
      {
                      if(p[i]==n-1) printf("%d",i);
      }
      
}
int main()
{
	char v[N];
	int n,i,j,a,b;
	int sign;

	scanf("%d",&n);
	for (i=0;i<n;i++)
		v[i]=1;
	while (1)
	{
		scanf("%d %d",&a,&b);
        if (a==0 && b==0)
			break;
		if (a!=b)
	    	v[a]=0;
	}
	sign=0;
	for (i=0;i<n;i++)
		if (v[i]==1)
		{
				if (sign==0)
					sign=1;
				printf("%d\n",i);

		}
	if (sign==0)
		printf("NOT FOUND\n");    
	return 0;
}
/******************************
 *No.1                        *
 *Title:Celebrity             *
 *Author:??                 *
 *Created on:2011.12.7        *
 ******************************/
int main()
{
	int n,i,j,flag = 1,a[100000] = {0};
	int *p = a;
	cin >> n;
	while(i != 0 || j != 0)
	{
		cin >> i >> j;
		a[j]++;
	}
	for(j = 0 ; j < n ; j++)
	{
		if(*(p + j) == n - 1 || *(p + j) == n)
		{
			cout << j << endl;
			flag = 0;
		}
	}
	if(flag)
	{
		cout << "NOT FOUND" << endl;
	}
	return 0;
}
main()
{ int a[50000],b[50000];
  int i,j,k,n,p,q,flag;
  scanf("%d",&n);
  for (i=0;i<n;i++)
  { a[i]=0; b[i]=0;}
  scanf("%d %d",&p,&q);
  while ((p+q)!=0)
  { a[p]++; b[q]++;
    scanf("%d %d",&p,&q);
   }
  for (i=0;i<n;i++)
    if ((a[i]==0)&&(b[i]==n-1)) {flag=1; printf("%d\n",i); }
  if (flag==0) printf("NOT FOUND");

}
main()
{
      int n,i,k=0;
      scanf("%d",&n);
      
      int *p,*q;
      //p=new int[n];
      //q=new int[n];
      p=(int*)malloc(n*sizeof(int));
      q=(int*)malloc(n*sizeof(int));
      for(i=0;i<n;i++)
      {
                     q[i]=0;    //??????????? 
                     p[i]=0;    //?????????? 
      }
      int a,b;
      do
      {
          scanf("%d %d",&a,&b);
          p[a]++;
          q[b]++; 
      }
      while(a!=0||b!=0);
      p[0]--;
      q[0]--;
      for(i=0;i<n;i++)
      {
                      if(q[i]==n-1&&p[i]==0)
                      {
                                          k++;
                                          printf("%d\n",i);
                      }
      }
      if(k==0)
      printf("NOT FOUND");
      free(q);
      free(p);
      getchar();
      getchar();
}
int main()
{
int n,i,j,k=0,P[10000]={0};
scanf ("%d",&n);
/*int*P=(int*)malloc(n*sizeof(int));
for(i=0;i<n;i++)
{
P[i]=0;                
}*/
for (;;)
{
scanf ("%d%d",&i,&j);
if (i==0&&j==0)
break;
P[j]++;
if (P[j]==(n-1))
{
printf("%d",j);k=1;break;}

}     
if(k==0)
printf("NOT FOUND") ;
}
main()
{
	int n=0,c=0,flag=0;
	int x[80000],y[80000],z[80000];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		z[i]=1;
	}
	for(int i=0;;i++)
	{
		scanf("%d %d",&x[i],&y[i]);
		if(0==x[i] && 0==y[i])
		{
			c=i;
			break;
	    }	
	}
	for(int i=0;i<c;i++)
	{
		z[x[i]]=z[x[i]]-1;
		z[y[i]]=z[y[i]]+1;
	}
	for(int i=0;i<n;i++)
	{
		if(z[i]==n)
		{
			printf("%d",i);
			flag=1;
		}
	}
	if(flag==0)
	printf("NOT FOUND");
//printf("0");
}
int main()
{
	int n;
	cin>>n;	
	int i;
	int flag=0;
	int a[10000];
	for(i=0;i<10000;i++)
	{
		a[i]=0;
	}
	int x,y;
	while(cin>>x>>y)
	{
		if(x==0&&y==0)
			break;
		a[y]++;
	}
	for(i=0;i<10000;i++)
	{
		if(a[i]==n-1)
		{	
			cout<<i<<endl;
			flag=1;
			break;
		}
	}
	if(flag==0)
		cout<<"NOT FOUND"<<endl;
	return 0;
}
main()
{
  int n,i,j,k=0;
  scanf("%d",&n);
  int*a=(int*)malloc(n*sizeof(int));
  int*b=(int*)malloc(n*sizeof(int));
  for(i=0;i<n;i++)a[i]=0;
  for(i=0;i<n;i++)b[i]=0;
  scanf("%d %d",&i,&j);
  while((i+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",i);
      k=1;
    } 
  }               
  if(k==0)printf("NOT FOUND");
  free(a);
  free(b);
  getchar();
  getchar();
  getchar();
  getchar();
}
int main()
{
    int n;
    scanf("%d",&n);
    int i,j,k,c[2][n],l;
    i=1;
    j=1;
    l=1;
    for(k=0;k<n;k++)
    {
                   c[0][k]=0; 
                   c[1][k]=0;
    }
    for(;;)
    {
                 scanf("%d %d",&i,&j);
                 if((i+j)==0)
                 break;
                 c[0][i]++;
                 c[1][j]++;
                 }
    for(k=0;k<n;k++)
    {
                 
                    if(c[0][k]==0&&c[1][k]==n-1)
                    {
                                                printf("%d\n",k);
                                                l++;
                    }
    }
    if(l==0)
    printf("NOT FOUND");
       }
int main()
{
    int a[100000],b[100000];
    int c,d,i,j,p,n,s,k;
    scanf("%d",&n);
    c=1;
    d=1;
    i=0;
    while(c!=0||d!=0)
    {
    scanf("%d %d",&a[i],&b[i]);
    c=a[i];
    d=b[i];
    i=i+1;
    }
    for(j=0,s=0;j<i-2;j++)
    {
    for(k=j+1,p=0;k<i-1;k++)
    if(b[j]==b[k])
    p=p+1;
    if(p==n-2)
    {
    printf("%d",b[j]);
    s=s+1;
    }
    }
    if(s==0)
    printf("NOT FOUND\n");
    getchar();
    getchar();
}
main()
{   int n;
    int i,j;
    int flag=0;
    scanf("%d",&n);
    int*p=(int*)malloc(n*sizeof(int));
    for(int k=0;k<n;k++)
    {p[k]=0;
    }    
    for(;;)
   {scanf("%d %d",&i,&j);
    if ((i==0)&&(j==0))
    break;
    p[j]+=1;
   }
    for(int o=0;o<n;o++)
   {if(p[o]==n-1)
    {printf("%d\n",o);
     flag+=1;
    }
   }
   if(flag==0)
   printf("NOT FOUND");
}
main()
{
      int n,x,y,i;
      int a[100000];
      int b[100000];
      scanf("%d",&n);
     while(1)
       {
              scanf("%d %d",&x,&y);
              if(x==0&&y==0)
              break;
              else
              {a[x]=1;b[y]++;}
      }
      for(i=0,x=0;i<=n-1;i++)
      {
                       if(a[i]==0)
                       {x++;y=i;}
      }
      if(x==1&&b[y]==n-1)
      printf("%d",y);
      else
      printf("NOT FOUND");
}
int main()
{ 
	int a[100000] = {0};
	int n, x, y, i;
	cin >> n;
	while (1)
	{
		cin >>  x >> y;
		if (y == 0 && x == 0)
			break; 
		(*(a + y))++;
		(*(a + x))--;
	}
	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,m,i,j,k,a[100000]={0},c[100000]={0},b[100000]={0};
     m=0;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     c[i]=i;
     for(i=0,j=0;;i++,j++)
     {
     scanf("%d %d",&a[i],&b[i]);
     if(a[i]==0&&b[i]==0)
     break;
     }
     for (k=0;k<n;k++)
     {
       for(i=0;i<j;i++)
       {
           if (a[i]==c[k])
           break;
           else if (b[i]==c[k])
           m=m+1;
       }
       if (m==(n-1))
       {
           printf("%d",c[k]);
           break;
       }
       m=0;
     }
}
void Qsort(int a[],int low,int up)
{
    int i,j,k,x;
    if (low>=up) return;
    else
    {
        k=a[low];
        j=low;
        for (i=low;i<=up;i++)
        {
            if (a[i]>k)
            {
                j++;
                x=a[i];
                a[i]=a[j];
                a[j]=x;
            }
        }
        x=k;
        a[low]=a[j];
        a[j]=x;
        Qsort(a,low,j-1);
        Qsort(a,j+1,up);
        
    }}
/*int main()
{
    int n,i,j,w,l;
    int a[1000],b[1000];
    scanf("%d",&n);
    while(n!=0){
    for(i=0;i<n;i++)
            a[i]=b[i]=0;
    for (i=0;i<n;i++)
        scanf("%d",&a[i]);
    for (i=0;i<n;i++)
        scanf("%d",&b[i]);
    Qsort(a,0,n-1);
    Qsort(b,0,n-1);
    w=l=0;
        j=0;
    for(i=0;i<n;i++)
    {
        while (a[i]<b[j])j++;
        if (j>=n) {l++;continue;}
        else
        {
            if (a[i]>b[j]) w++;
            j++;
        }
    }
    printf("%d\n",w*200-200*l);
    scanf("%d",&n);
    }
}*/
int main()
{
    int know[10000]={0},beknown[10000]={0};
    int n=0,i,x,y,flag,t;
    scanf("%d",&n);
    x=y=1;
    t=0;
know[0]=beknown[0]=-1;
    while(x+y!=0)
    {
        scanf("%d %d",&x,&y);
        know[x]++;
        beknown[y]++;
    }
    flag=0;
    for (i=0;i<n;i++)
    {
        if ((know[i]==0)&&(beknown[i]==n-1)){flag=1;t=i;}
    }
    if (flag==1) printf("%d",t);
    else {
        printf("NOT FOUND");
    }
        
}
int main()
{
	int n, a[10000][2];
	int i, j;
	scanf( "%d", &n );
	for( i = 0; i < n; i++ ) {
		a[i][0] = 0;
		a[i][1] = 0;
	}
	while( scanf( "%d%d", &i, &j ) ) {
		if( i==0 && j == 0 )
			break;
		a[i][0] += 1;
		a[j][1] += 1;
	}
	for( i = 0; i < n; i++ )
		if( a[i][0] == 0 && a[i][1] == n - 1 ) {
			printf( "%d\n", i );
			break;
		}
	if( i == n )
		printf( "NOT FOUND\n" );
	return 0;
}
int main()
{
    int n,a[1000000],b[100000],i=1,j=1;
    scanf("%d",&n);
    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]=a[i]+1;
          b[j]=b[j]+1;
    }
    for(int k=0;k<n;k++)
    {
            if(b[k]==n-1&&a[k]==0)
            printf("%d\n",k);
    }
}
int main()
{
	int n,shuru=0,r=0;
	int i,j;
	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;}
		else { shuru++;}
	}
	for(i=0;i<shuru;i++)
	{
		r=0;
		for(j=1;j<shuru-i;j++)
		{
			if(b[i]==b[i+j])
			{
				r++;
			}
			if(r==n-2)
			{
				printf("%d",b[i]);
				break;
			}
		}
		if(r==n-2)
		{
			break;
		}

	}
	if(i==shuru)
	{
		printf("NOT FOUND");
	}
return 0;
}
main()
{
      int n,a,b,c[10000],d[10000],i,j=0;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
          c[i]=0;
          d[i]=0;
      }
      while(1)
      {
           scanf("%d %d",&a,&b);
           if(a==0&&b==0)
           break;
           else
           {
               c[a]++;
               d[b]++;
           }
      }
      for(i=0;i<n;i++)
      {
           if(c[i]==0&&d[i]==n-1)
           {
                 printf("%d",i);
                 j=1;
                 break;
           }
      }
      if(j==0)
      printf("NOT FOUND"); 
      getchar();
      getchar();
}
main()
{
      int n,i,j,k,a[20000],b[20000];
      for(k=0;k<20000;k++)
      {
         a[k]=0;
         b[k]=0;
      }
      scanf("%d",&n);
      scanf("%d %d",&i,&j);
      while((i+j)!=0)
      {
           a[i]++;
           b[j]++;
           scanf("%d %d",&i,&j);           
      }      
      for(k=0;k<=n-1;k++)
         if(b[k]==n-1&&a[k]==0)
         {
             j=0;
             break;
         }
      if(j)
      printf("NOT FOUND");
      else
      printf("%d",k);
}
int main(void)
{
	int g=0,e=0;
	scanf("%d",&g);
	int *p=NULL,*a=NULL;
	p=(int *)malloc(g*g*sizeof(int));
	a=(int *)malloc(g*sizeof(int));

	//int p[10],a[3];
	for(int i=0;i<g;i++)
	{
		a[i]=88888;										//?????88888??
	}
	
	for(int i=0;i<g*g;i++)
	{
		p[i]=burenshi;
	}

	for(int i=0;i<g;i++)
	{
		p[i*g+i]=ziji;
	}

	int m=0,n=0;
	for(;;)
	{
		scanf("%d %d",&m,&n);
		if(m==0&&n==0)
		{break;}
		p[m*g+n]=renshi;
	}

	for(int i=0;i<g;i++)
	{
		int beknown=1,know=0;
		for(int j=0;j<g;j++)
		{
			know=know+p[i*g+j];
		}
		
		if(know!=ziji)
		{continue;}
		
		for(int j=0;j<g;j++)
		{
			beknown=beknown*p[j*g+i];
		}
		if(beknown==0)
		{
			continue;
		}

		a[e]=i;
			e++;
	}
	
	if(a[0]==88888)
	{printf("NOT FOUND");}
	
	else
	{
		for(int i=0;;i++)
	
		{
			if(a[i]==88888)
			{break;}

		printf("%d\n",a[i]);
		}
	}

	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;
}