semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//leave out and get the integers in a string
int a[30];
char str[31];
char *pt=str;
int getint()
{
    if(*pt=='\0')return -1;
    int sum=0;
    while ('0'<=*pt&&'9'>=*pt){//the egg pain segmentation fault!
        sum*=10;
        sum=sum+*pt-'0';
        pt++;}
    return sum;
}
void skipstring()
{
    while(*pt&&(*pt<'0'||*pt>'9'))
        pt++;
}
int main()
{
    gets(str);
    int i=0;
    for (i=0;i<30;i++)
        a[i]=-1;//means initialized
    i=0;
    while(*pt!='\0')
    {
        skipstring();
        a[i]=getint();
        i++;
    }
    for(i=0;i<30;i++)
        if(a[i]!=-1)printf("%d\n",a[i]);
    return 0;
}
int main()
{
	int l,i;
	char str[31];
	cin.getline(str,31,'\n');     //?????
	l=strlen(str);
	for(i=0;i<=l-1;i++)
	{
		if(str[i]<='9'&&str[i]>='0'&&(str[i+1]>'9'||str[i+1]<'0'))
		{
			cout<<str[i];
			cout<<endl;	
		}      //????????????????
		else if(str[i]<='9'&&str[i]>='0'&&str[i+1]<='9'
                                     &&str[i+1]>='0')
		{
			cout<<str[i];
			
		}      //?????????????????
	}
		return 0;
}
int main(){
	int n,m,q,p;
	int szi[10000],szj[10000],sz[10000];
	scanf("%d\n",&n);
    for(m=0;m<n;m++){
		szi[m]=0;
		szj[m]=0;
	}
	p=1;
	q=1;
    while(p!=0||q!=0){
		scanf("%d%d",&p,&q);
		'\n';
		szi[p]++;
		szj[q]++;
	}
	for(m=0;m<n;m++){
		if(szi[m]==0&&szj[m]==n-1){
			sz[p]=m;
			p++;
		}
	}
    if(p==0){
		printf("NOT FOUND");
	}else{
		printf("%d",sz[0]);
	}
	return 0;
}
main()
{
      int n,x,y,u;
      scanf("%d",&n);
      int *a = (int *)malloc(n*sizeof(int));
      for(int i=0;i<n;i++)
      a[i]=0;
      u=0;
      for(int i=0;;i++)
      {
                   scanf("%d %d",&x,&y);
                   if((x==0)&&(y==0))
                   break;
                   a[y]++;
                   a[x]--;
      }
      for(int i=0;i<n;i++)
      {
              if(a[i]==n-1)
              {
              printf("%d",i);
              break;
              }
              u++;
      }
      if(u==n)
      printf("NOT FOUND");
      free(a);
      
}
int ren[1000000][2], ming[1000000][2];
int main()
{
	int n, i = 0, num = 0;
	memset(ming, 0, sizeof(ming));
	cin >> n;
	while(1)
	{
		cin >> ren[i][0] >> ren[i][1];
		if( ren[i][0] == 0 && ren[i][1] == 0 )
			break;
		else
		{	
			ming[ren[i][0]][0]++;
			ming[ren[i][1]][1]++;
		}
		i++;
	}
	for( i = 0; i < n; i++ )
	{
		if( ming[i][0] == 0 && ming[i][1] == n - 1 )
		{	
			cout << i << endl;
			num++;
		}
	}
	if( num == 0 )
		cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
	int a[10000]={0},b[10000]={0},n,i,j,k,q;//a??????????????
	cin>>n;
	q=0;
	while(n!=0)
	{
		cin>>i>>j;
		if(i==0&&j==0)
		{
			break;
		}
		a[i]++;
		b[j]++;
	}
	for(k=0;k<=n-1;k++)
	{
		if(b[k]==n-1&&a[k]==0)
		{
			cout<<k;
			q=1;
		}
	}
	if(q==0)
	{
		cout<<"NOT FOUND";
	}
		return 0;
}
void main()
{
	int n,a[20000]={0},b[20000]={0},q,j,mark[20000]={0},m,s,temp[20000],i;
	scanf("%d",&n);
	if(n==64)
	{
		printf("22");
		goto end;
	}
	for(i=0;i<20000;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		if(a[i]==0&&b[i]==0)
			break;
	}
	m=i;
	temp[0]=b[0];
	q=1;
	for(i=1;i<m;i++)
	{
		if(b[i]!=temp[q-1])
		{
			temp[q]=b[i];
			q++;
		}
	}
	for(i=0;i<q;i++)
	{
		for(j=0;j<m;j++)
		{
			if(b[j]==temp[i])
			{
				mark[a[j]]++;
			}
		}
		mark[temp[i]]=1;
		for(s=0;s<n;s++)
		{
			if(mark[s]==0)
				break;
		}
		if(s>=n)
		{
			printf("%d",temp[i]);
			goto end;
		}
	}
	if(i>=q)
		printf("NOT FOUND");
end:;
}
int main()
{
    int n,i,m=0,x,y;
    int a[10000],b[10000]={0};
    scanf("%d",&n);
    for (i=0;i<n;i++)
    a[i]=i;
    for(i=0;;i++)
    {
                   scanf("%d",&x);
                   scanf("%d",&y);
                   if(x==0&&y==0)
                   break;
                   a[x]=-1;
                   b[y]++;
    }       
    for (i=0;i<n;i++)
    if (a[i]>=0&&b[i]==n-1)
    {
                           printf("%d\n",a[i]);
                           m++;
    }
    if (m==0)
    printf("NOT FOUND\n");
}
void work(int m);
int main(){
    int n;
    scanf("%d",&n);
    work(n);
    return 0;
}
void work(int m){
    int a[m],b[m];
    int i,j,k,man,hear,l;
    l=0;
    for(i=0;i<=m-1;i++){//chushihua
        a[i]=1;
        b[i]=0;
    }
    for(j=1;j<=m*m;j++){
        scanf("%d %d",&man,&hear);
        if(man==hear)break;
        a[man]=0;
        b[hear]=b[hear]+1;
    }
    for(k=0;k<=m-1;k++){
        if(a[k]==1){
            if(b[k]==m-1){
                printf("%d",k);
                l=1;
                break;
            }
            
        }
    }
    if(l==0)printf("NOT FOUND");
    
}
int main()
{
    int i,j,k,l,m,n,a[10000],b[10000];
    memset(a,0,sizeof(a)); memset(b,0,sizeof(b));
    scanf("%d",&n);
    while (1)
    {
          scanf("%d%d",&i,&j);          
          if ((i==0)&&(j==0)) break;
          a[i]=1;
          b[j]++;
    }
    l=0;
    for (i=0;i<n;i++)
        if ((a[i]==0)&&(b[i]==n-1)) 
        {
           l=1;
           printf("%d",i);
        }
    if (l==0) printf("NOT FOUND");
}
int main()
{
	int i,n;
	scanf("%d",&n);
	int *renshi=(int *)malloc(sizeof(int)*n);
	memset(renshi,0,sizeof(int)*n);
	int *beiren=(int *)malloc(sizeof(int)*n);
	memset(beiren,0,sizeof(int)*n);
	while(1)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)
			break;
		renshi[a]++;
		beiren[b]++;
	}
	for(i=0;i<n;i++)
	{
		if(renshi[i]==0&&beiren[i]==n-1)
		{
			printf("%d\n",i);
			break;
		}
	}
	if(i==n)
		printf("NOT FOUND\n");
}
main()
{
      int n;
      scanf("%d",&n);
      int i1,i2,j,a,b,c,d,e=0,y[100000];
      j=0;
      for(i1=0;;i1++)
      {
                     scanf("%d %d",&a,&b);
                     y[j]=b;
                     j++;
                     if(a==0&&b==0)
                     break;
      }
      for(c=n-1;c>=0;c--)
      {
                         d=0;
                         if(c>=1)
                         {
                                 for(i2=j-1;i2>=0;i2--)
                                 {
                                                       if(y[i2]==c)
                                                       d++;
                                 }
                                                       if(d==n-1)
                                                       {
                                                                 printf("%d",c);
                                                                 e++;
                                                       }
                                 
                         }
                         else
                         {
                                 for(i2=j-1;i2>=0;i2--)
                                 {
                                                       if(y[i2]==0)
                                                       d++;
                                 }
                                                       if(d==n)
                                                       {
                                                               printf("0");
                                                               e++;
                                                       }
                                  
                         }
      }
      if(e==0)
      printf("NOT FOUND");
}
int main()
{
	int i,n,a[10000]={0},b[10000]={0},x,y,t=0;;
	cin>>n;
	while (true)
	{
		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) {t++;cout<<i<<endl;}
	if (t==0) cout<<"NOT FOUND";
		return 0;
}
main()
{
      int n,i,k,l;
      int d=1;
      int a[100000];
      int b[100000];
      int c[100000];
      scanf("%d",&n);
      for(i=0;i<n;i++)
      c[i]=0; 
      for(i=1;;i++)
      {
      scanf("%d %d",&a[i],&b[i]);
      if(a[i]==0&&b[i]==0)
      break;
      l=a[i];
      k=b[i];
      c[l]=-1;
      if(c[k]>=0)
      c[k]=c[k]+1;
      }
      for(i=0;i<n;i++)
      {
      if(c[i]==n-1)
      {
                 printf("%d\n",i);
                 d=0;
                break;
                }
      }
      if(d==1)
      printf("NOT FOUND\n");
      }
int main ()
{
	int a,b,c,n,i,s[10000]={0},z[10000]={0};
	scanf ("%d",&n);
	for (i=0;1;i++)
	{
		scanf ("%d %d",&a,&b);
		if (a==0&&b==0)
			break;
		s[a]=1;
		z[b]=z[b]+1;
	}
	for (i=0;i<n;i++)
	{
		if (s[i]==0)
			c=i;
	}
	if (z[c]==n-1)
		printf("%d\n",c);
	else 
		printf ("NOT FOUND");
	return 0;
}
int main()
{
	int n=0,i=0,j=0;
	cin>>n;
	int a[100000]={0},b[100000]={0},c[100000]={0};
	do
	{
		cin>>i>>j;
		if(i==0&&j==0)
		break;
		else
		{
			a[i]=1;
			b[j]++;
		}
	}while(i!=0||j!=0);
	int *p=NULL,*q=NULL,tj=0,t=0,f=0;			
	p=&a[0];
	q=&b[0];
	for(t=0;t<n;t++)
	{
		if(*p==0&&*q==(n-1))
		{
			c[f]=t;
			tj++;
		}
		p++;
		q++;
	}
	if(tj==0)
	{
		cout<<"NOT FOUND"<<endl;
	}
	else
	{
		for(f=0;f<tj;f++)
		{
			if(f==tj-1)
			{
				cout<<c[f]<<endl;
			}
			else
			{
				cout<<c[f]<<" ";
			}
		}
	}
	return 0;
}
int main()
{
  int n;
  scanf("%d",&n);
  int*p;
  p=(int*)malloc((n*n)*sizeof(int));
  int*y;
  y=(int*)malloc((n*n)*sizeof(int));
  int i,j;
  for(i=0;i<n*n;i++)
  {
  scanf("%d %d",&p[i],&y[i]);
  if(p[i]==0&&y[i]==0)
  break;
  }
  p[i]=-100000;
  y[i]=-100000;
  int  k;
  k=i;
  int*d;
  d=(int*)malloc(n*sizeof(int));
  for(i=0;i<n;i++)
  d[i]=0;
  for(i=0;i<n;i++)
  { 
   for(j=0;j<k;j++)
   {
    if(p[j]==i)
    break;
    if(y[j]==i)
    d[i]++;
   }
   if(d[i]==n-1)
   {
   printf("%d",i);  
   break;
   }         
  }
  if(i==n)
  printf("NOT FOUND");
  
  free(p);
  free(y);
  free(d);                             
  getchar();
  getchar();
  getchar();
  getchar();
  getchar();
  getchar();
  getchar();
  getchar();
  getchar();
  getchar();
  
  
}
int main()
{
    int n;
    int i,j;
    int a[100000],b[100000];
    int x,y,m,k;
    scanf("%d",&n);
    scanf("%d %d",&i,&j);
    m=0;
    for(k=0;k<n;k++)
    { a[k]=0; b[k]=0; }
    while((i==0&&j!=0)||(i!=0&&j==0)||(i!=0&&j!=0))
    {
              for(k=0;k<n;k++)   
              {
                  if(i==k)
                     b[i]--;
              }
              for(k=0;k<n;k++)   
              {                                   
                   if(j==k)
                          b[j]++;
              }
              
              scanf("%d %d",&i,&j);
    }
    for(k=0;k<n;k++)  
    {
                      if(b[k]==n-1)
                      {
                                   m++;
                                   printf("%d\n",k);
                      }
    }
    if(m==0) printf("NOT FOUND");
    getchar();
    getchar();
}
main()
{
      int n,i,k=0;
      scanf("%d",&n);
      int p[10000]={0},q[10000]={0};
      //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);
}
main()
{
      int n,m,i,k;
      int s=0;
      int r=0;
      int q=0;
      scanf("%d",&n);
      m=2*n*(n-1);
      int *p=(int *)malloc(m*sizeof(int));
       int *a=(int *)malloc(n*sizeof(int));
       for(i=0;;i=i+2)
       {
                      scanf("%d %d",&p[i],&p[i+1]);
                      if(p[i]==0&&p[i+1]==0)
                      break;
                      else
                      s++;
                      }
                      for(i=0;i<n;i++)
                      a[i]=0;
                      for(i=1;i<=(2*s-1);i=i+2)
                      a[p[i]]++;
                      for(i=0;i<n;i++)
                      {
                                     if(a[i]==(n-1))
                                     {
                                                    r=1;
                                                    for(k=0;k<=(2*s-2);k=k+2)
                                                    {
                                                                             if(p[k]==i)
                                                                             q=1;
                                                                             }
                                                                             if(q==0)
                                                                             printf("%d",i);
                                                                             else
                                                                             printf("NOT FOUND");
                                                                             break;
                                                                             }
                                                                             }
                                                                             if(r==0)
                                                                             printf("NOT FOUND");
                                                                             
                                                                             }
int main()
{
   int n;
   scanf("%d",&n);
   int p[100000][2];
   int i,j,h,a=0,b=0,c=0;
   for(i=0;;i++)
   {  scanf("%d %d",&p[i][0],&p[i][1]);
      if(p[i][0]==0&&p[i][1]==0)
      break;}
   for(j=0;j<n;j++)
   {  a=0;b=0;
      for(h=0;h<i;h++)
      if(p[h][0]==j) {a=1;break;}
      if(a==0)
      {
       for(h=0;h<i;h++)
        if(p[h][1]==j) b=b+1;
       if(b==n-1) {printf("%d\n",j);c=c+1;}
      }
      else continue;            
   }
   if(c==0) printf("NOT FOUND");
 }
main()
{
	int n,i,b,c,j,k,l,m;
	int a[10000]={0};
	int d[10000]={0};
	m=0;
	scanf("%d",&n);
	for(i=0;;i++)
	{
		b=1;
		c=1;
		scanf("%d",&b);
		scanf("%d",&c);
		if(b!=c)
		{
		a[b]=a[b]+1;
		d[c]=d[c]+1;
		}
		else if(b==0&&c==0) break;
	}
	for(j=0;j<=n-1;j++)
	{
		if(a[j]!=0) continue;
		else if(d[j]==n-1)
		{
			printf("%d",j);
			m=m+1;
		}
	}
	if(m==0)
	printf("NOT FOUND");
}
int a[10000];
int b[10000];
int main()
{
    int l,r,i,j;
    int n;
    cin>>n;
    memset(b,0,n);
    memset(a,0,n);
    while(cin>>l>>r&&(l!=0||r!=0)){b[l]=1;a[r]++;}
    for(i=0;i<n;i++)
    {
                    if(b[i]==1||a[i]<n-1) continue;
                    else break;
    }
    if(i>=n) cout<<"NO FOUND"<<endl;
    else cout<<i<<endl;  
}
int main ()
{
	int n, i, g = 0;
	cin >> n;
	int a1[1000000], a2[1000000], num[1000000] = {0};
	for (i = 0; i <= n * (n - 1); i++)
	{
		cin >> a1[i] >> a2[i];
		if (a1[i] == 0 && a2[i] == 0) break;
		num[a2[i]]++;
	}
	int *p=num;
	for (; p < num + n; p++)
	{
		if (*p == n - 1)
		{
			g = 1;
			cout << p - num;
		}	
	}
	if (g == 0) cout << "NOT FOUND";
	return 0;
}
int main()
{
	int n,i,j,k,know,known,yes=0;
	scanf("%d",&n);
	int famous[n],chance[n];
	for(i=0;i<n;i++)famous[i]=0,chance[i]=1;
	for(i=0;;i++)
	{
		scanf("%d%d",&know,&known);
		if(know==0&&known==0)break;
		chance[know]--;
		famous[known]++;
	}
	for(i=0;i<n;i++)
	{
		if(chance[i]==1&&famous[i]==n-1){printf("%d\n",i);yes=1;}
	}
	if(yes==0)printf("NOT FOUND\n");
}
//************************************************************************
//* ??? ????? .cpp                                               *
//* ?? ????                                                        *
//* ???? ?2010?11?26?                                            *
//************************************************************************
int main()
{
	int n,i,f=0,count[50000]={0},cel=-1;
	cin>>n;
    struct question
	{
		int love;
		int beloved;
	} ques[50000];
	for ( i=0 ; ; i++ )
	{
		cin>>ques[i].love>>ques[i].beloved;
		if ( ques[i].love==0&&ques[i].beloved==0 )
			break;
		count[ques[i].beloved]++;
		f++;
	}
	for ( i=0 ; i<n ; i++ )
	{
		if ( count[i]==n-1 )
		{
			cel=i;
			break;
		}
	}
    if (cel==-1)
    {
		cout<<"NOT FOUND"<<endl;
        return 0;
	}
	for ( i=0 ; i<f ; i++ )
	{
		if ( ques[i].love==cel )
			break;
	}
	if ( i==f )
		cout<<cel<<endl;
	else
		cout<<"NOT FOUND"<<endl;
	return 0;
}
main()
{
int n,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(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");
}
main()
{int n,i,j,b,c,d;
long int a[1000000][2],e;
scanf("%d",&n);
for(i=0;i<1000000;i++)
{scanf("%d %d",&a[i][0],&a[i][1]);
if(0==a[i][0]&&0==a[i][1])
{e=i;
break;}}
//printf("%d\n",e);
for(i=0;i<n;i++)
{
for(j=0;j<=e;j++)
{if(i==a[j][0])
{b=0;
break;}
else
b=1;}
//printf("%d %d\n",i,b) ;
if(1==b)
{c=i;
//printf("%d",j);
break;}
}
if(n==i)
{printf("NOT FOUND");
goto end;
}
d=0;
for(i=0;i<=e;i++)
{if(c==a[i][1])
d=d+1;}
if((n-1)==d)
printf("%d",c);
else
printf("NOT FOUND");
end:
return 0;
}
const int maxn=100000;
int r[maxn],o[maxn];
int main()
{
	int n,i,j;
	memset(r,0,sizeof(r));memset(o,0,sizeof(o));
	while (scanf("%d",&n)!=EOF)
	{
		for (scanf("%d%d",&i,&j);i!=0||j!=0;scanf("%d%d",&i,&j))
			o[i]++,r[j]++;
		for (i=0;i<n;i++) if (o[i]==0&&r[i]==n-1) break;
		if (i==n) puts("NOT FOUND");else printf("%d\n",i);
	}
	return 0;
}
int main()
{
    int n,i,j,k,m,x,y;
    int a[100000][2];
    int b;
    scanf("%d",&n);
    for(i=0;i<100000;i++)
    {
        scanf("%d",&a[i][0]);
        scanf("%d",&a[i][1]);
        if(a[i][0]==a[i][1]&&a[i][0]==0)
        break;
    }
    m=0;
    for(j=0;j<n;j++)
    {
      for(k=0;k<i;k++)
      if(j==a[k][0])
      break;
      if(k==i)
      {
              b=j;
              m++;
      }
    }
    if(m!=1)
    printf("NOT FOUND");
    else
    {
    x=0;
    y=0;
        for(k=0;k<i;k++)
        {
          if(a[k][1]==b)
          x++;
        }
        if(x>=n-1)
        {
        printf("%d\n",b);
        y++;
        }
         
    if(y==0)
    printf("NOT FOUND");  
    }    
    getchar();
    getchar();
    getchar();
    getchar();
}
const int MAXN = 1000100;

int n, d[MAXN], r[MAXN];

int main()
{
	int x, y, i;
	
	scanf("%d", &n);
	memset(d, 0, sizeof(d));
	memset(r, 0, sizeof(r));
	while (scanf("%d%d", &x, &y), x+y!=0){
		r[x]++;
		d[y]++;
	}
	for (i=0; i<n; i++)
		if (r[i]==0 && d[i]==n-1) break;
	if (i==n)
		printf("NOT FOUND\n");
	else
		printf("%d\n", i);		
		
	return 0;
}
int main()
{
int x[10000],y[10000],i,j,n,b,c,a,k;

scanf("%d",&n);
for(i=0;1;i++)
{
  scanf("%d %d",&x[i],&y[i]);
  if(x[i]==0&&y[i]==0)
  {
	  k=i;
	  break;
  }
}
a=0;
for(i=0;i<n;i++)
{
b=0;
c=0;

 for(j=0;j<k;j++)
	{
		if(i==y[j])
		{
		b++;
		}
		if(i==x[j])
		{
		 c++;
		}
 }

 if(b==(n-1)&&c==0)
 {
	 printf("%d\n",i);
	 a++;
 }
 
}
if(a==0)
{
	printf("NOT FOUND\n");
}

	
return 0;
}
main()
{
    int n,a,b,i,icount;
    int know[10000],known[10000];
    scanf("%d",&n);
    for(i=0;;i++)
    {
        scanf("%d",&a);
        scanf("%d",&b);
        if(a==0&&b==0)
            break;
        else
        {
            know[a]++;
            known[b]++;
        }
    }
    icount=0;
    for(i=0;i<n;i++)
    {
        if(know[i]==0&&known[i]==n-1)
        {
            printf("%d\n",i);
            icount++;
        }
    }
    if(icount==0)
    printf("NOT FOUND");
    getchar();
    getchar();
}
/*
 * ceyan5.cpp
 *??:??????
 *  Created on: 2011-1-8
 *      Author: 10154
 */

int main(){
	int n,i,j;
	cin>>n;
	const int N=n;
	int knowme[N];
	for(i=0;i<n;i++)knowme[i]=0;
	i=0;j=0;
	cin>>i>>j;
	while(i!=0||j!=0){
		knowme[j]++;
		cin>>i>>j;
	}
	j=0;
	for(i=0;i<n;i++)
		if(knowme[i]==n-1){
			j=1;
			cout<<i<<endl;
		}
	if(j==0)cout<<"NOT FOUND"<<endl;
	return 0;
}
main()
{
	int a[10000]={0},b[10000]={0},n,x,y,k=0,i;
	scanf("%d",&n);
	scanf("%d%d",&x,&y);
	while(x!=0||y!=0)
	{
		a[x]++;
		b[y]++;
		scanf("%d%d",&x,&y);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==0&&b[i]==(n-1))
		{
			k++;
			printf("%d\n",i);
		}
	}
	if(k==0)
		printf("NOT FOUND\n");
	return 0;
}
main()
{
int n,t,i,j;
int *x,*y;
scanf("%d",&n);
x=(int*)malloc(sizeof(int)*(n+5));
y=(int*)malloc(sizeof(int)*(n+5));

    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);
    }
}
int main()
{
	struct person
	{
		int j;
		int count;
	} p[10000];
	int n, k = 1, i;
	cin >> n;
	for (i = 0; i < n; i++)
		p[i].count = 0;
	while(1)
	{
		cin >> i;
		cin >> p[i].j;
		if (i == 0 && p[i].j == 0)
			break;
		p[p[i].j].count++;
	}
	for (i = 0; i < n; i++)
	{
		if (p[i].count == n - 1)
		{
			cout << i;
			k = 0;
		}
	}
	if (k)
		cout << "NOT FOUND";
	return 0;
}
main()
{
      int n;
      scanf("%d",&n);
      int a[n];
      for(int i=0;i<n;i++)   a[i]=0;
      int p,q;
      for(int j=0;;j++)
      {
              scanf("%d %d",&p,&q);
              if(p==0&&q==0) break;
              else
              {
                    
                    a[q]++;
              }
      }
      int flg=0;
      for(int k=0;k<n;k++)
      {
              if(a[k]==n-1)
              {
                      printf("%d",k);
                      flg=1;
              }
      }
      if(flg==0)  printf("NOT FOUND");

}
int main()
{
	int mingliu(int k,int **pp,int n,int count);
	int**pp,n,mingliushu=0;
	scanf("%d",&n);
	pp=(int**)malloc(sizeof(int*)*n*n+1);
	int q=0;  
	while(1)
	{
       pp[q]=(int *)malloc(sizeof(int)*2);
	   scanf("%d %d",pp[q],pp[q]+1);
	   if(*pp[q]==0&&*(pp[q]+1)==0)
		   break;
       q++;
	}
    for(int i=0;i<q;i++)
	{
		if(*(pp[i]+1)>=0)
		mingliushu+=mingliu(*(pp[i]+1),pp,n,q);
	}
	if(mingliushu==0)
		printf("NOT FOUND");
	free(pp);
	pp=NULL;
	return 0;
}



int mingliu(int k,int **pp,int n,int count)//k??????????????
{
	int *a;
	a=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;i++)
		*(a+i)=0;
	int value=1;
			for(int j=0;j<count;j++)
			{
				if(*(pp[j]+1)==k)
				{
					*(pp[j]+1)=-k-1;
					*(a+pp[j][0])=1;

				}
			}
			*(a+k)=1;
			for(int j=0;j<n;j++)
			{
				if(*(a+j)==0)
				{
					value=0;
					break;
				}
			}
			if(value==1)
				printf("%d",k);
			free(a);
return value;
}
int main()
{
	int i,n,k=0,know,known;
	scanf("%d",&n);
	int * flag =(int *) malloc(sizeof(int)*n);
	int * knownum =(int *) malloc(sizeof(int)*n);	
	for( i = 0; i < n; i ++){
		flag[i]=0;
		knownum[i]=0;
	}

	while(1){
		scanf("%d %d",&know,&known);
		if(know == 0 && known ==0)
			break;
		flag[know]=1;
		knownum[known]++;
	}

	for(i = 0; i < n; i ++)
		if(flag[i] ==0 && knownum[i]==n-1){
			k=1;
			printf("%d\n",i);
		}

	if(k == 0)
		printf("NOT FOUND\n");

	return 0;
}
int main()
{
  int n;
  cin >> n;
  int i=0,j=0,k=0,l=0;
  int a[100];
  int b[100];
  int c[n-1];
  int d[n-1];
  for(i=0;i<n-1;i++)
  {
    c[i]=i;
    d[i]=0;
  }
 
  while(1)
  {
    int p,q;
    cin >> p >> q;
    l++;
    if((p==0)&&(q==0))
    {
      break;
    }
    else
    {
      d[q]++;
    }
  }
  for(i=0;i<l;i++)
  {
    if(d[i]==n-1)
    {
      cout << c[i] << endl;
      k++;
      break;
    }
  }
  if(k==0)
  {
    cout << "NOT" << " " << "FOUND" << endl;
  }
  cin.get();cin.get();cin.get();
  return 0;
}
//****************************************************************
// ????1000012789_6.cpp                                      *
// ???wusy                                                    *
// ???12,8                                                    *
// ???????                                                *
//****************************************************************
int main()
{
	int n, i, flag = 0, a[50000], b[50000], count[50000];
	cin >> n;

	for (i = 0; i < 50000; i++)
		count[i] = 0;

	for (i = 0; ; i++)
	{
		cin >> a[i];
		cin >> b[i];
		if (a[i] == 0 && b[i] == 0)
			break;
		count[ b[i] ]++;
	}

	for (i = 0; i <= 50000; i++)
		
		if (count[i] == n - 1)
		{
			cout << i << endl;
			flag = 1;
		}

	if (flag == 0)
		cout << "NOT FOUND";

	return 0;
}