semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int a[30000];
	int i,n,j,sum,biao;
	scanf("%d",&n);
	for(i=0;i<=29999;i++)
	{
		if(i<n)
		{
			a[i]=1;
		}
		else
		a[i]=0;
	}
	i=29999;
	j=29999;
	while(i!=0||j!=0)
	{
		a[i]=0;
		scanf("%d %d",&i,&j);
		
	}
	sum=0;
	for(i=0;i<30000;i++)
	{
		sum=sum+a[i];
	}
	biao=0;
	if(sum=1)
	{
		for(i=0;i<30000;i++)
		{
			if(a[i]==1)
			{
				printf("%d",i);
				biao=1;
			}
		}
	}
	if(biao==0)
		printf("NOT FOUND");

}
int flag[10000];
int num[10000];
int main()
{
	int n;
	cin>>n;
	int a = 1, b = 1;
	memset(flag, 0, sizeof(flag));
	memset(num, 0, sizeof(num));
	cin>>a>>b;
	while((a != 0)||(b != 0))
	{
		flag[a] = 1;
		num[b]++;
		cin>>a>>b;
	}
	int i;
	int j = 0;
	for(i = 0; i < n; i++)
	{
		if(flag[i] == 0 && num[i] == n - 1)
		{
			cout<<i<<endl;
			j = 1;
		}
	}
	if(j == 0)
		cout<<"NOT FOUND"<<endl;
	return 0;
}
int main()
{
	int n;
	int g1[100000] = {0};
	int g2[100000] = {0};
	int i, j;
	scanf("%d", &n);
	while (scanf("%d%d", &i, &j), i != 0 || j != 0)
	{
		g1[i]++;
		g2[j]++;
	}
	for (i = 0; i < n; i ++)
		if (g1[i] == 0 && g2[i] == n - 1)
		{
			printf("%d", i);
			break;
		}
	if (i == n)
	printf("NOT FOUND\n");
	return 0;
}
int main()
{
    int n,k,i,j,q,s=0;
    scanf("%d",&n);
    int*a=(int*)malloc(n*sizeof(int));
    int*b=(int*)malloc(n*sizeof(int));
    for(k=0;k<n;k++)
    {
                    a[k]=0;
                    b[k]=0;
    }
    for(k=0;;k++)
    {
                 scanf("%d %d",&i,&j);
                 if(i==0&&j==0) break;
                 a[i]+=1;
                 b[j]+=1;
    }
    for(k=0;k<n;k++)
    {
                    if(b[k]==n-1&&a[k]==0)
                    {
                                          printf("%d",k);
                                          s+=1;
                    }
    }
    if(s==0) printf("NOT FOUND");
    return 0; 
}
int main()
{
    int i,n,m;
    scanf("%d",&n);
    int a[100000][2],b[100000]={0};
    for(i=0;i<100000;i++)
    {
      scanf("%d %d",&a[i][0],&a[i][1]);
      if(a[i][0]==0&&a[i][1]==0)
      break;
      else
      {
        b[a[i][1]]++;  
      }             
    }
    for(i=0;i<n;i++)
    {
      if(b[i]==n-1)
      {
       printf("%d",i);
       break;
      }              
    }
    if(i==n)
    printf("NOT FOUND");
    getchar();
    getchar();
}
//********************************
//*?????????   **
//*?????? 1200012837 **
//*???2012.12.10  **
//********************************

struct k
{
	int know;
	int known;
}kk[10010];

int main()
{
	int n, i, j, flag = 0;
	cin >> n;
	cin >> i >> j;
	memset(kk,0,sizeof(k)*10010);
	while(i != 0 || j != 0)
	{
		kk[i].know++;
		kk[j].known++;
		cin >> i >> j;
	}
	for(;i < n; i++)
		if(kk[i].know == 0 && kk[i].known != 0)
		{
			cout << i << endl;
			flag = 1;
		}
	if(flag == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main(){
int n,num,a,ml=0;
int sz[100000][2];
scanf("%d",&n);
for (int i=0;;i++){
	for (int j=0;j<2;j++){
		scanf("%d",&sz[i][j]);
	}
	if (sz[i][0]==0&&sz[i][1]==0){
		break;
	}
}
for (int k=0;k<n;k++){
	num=n-1;
	a=0;
	for (int t=0;;t++){
		if (sz[t][0]==k){
			if(sz[t][1]==0&&sz[t][0]==0){
				break;
			}
			else {
		    a=1;	
			break;
		}
		}
        if (sz[t][1]==k){
			num--;
		}
		if (sz[t][0]==0&&sz[t][1]==0){
			break;
    	}
	}
	if (num==0&&a==0){
		ml=1;
		printf("%d",k);
		break;
	}
}
	if (ml==0){
		printf("NOT FOUND");
	}
return 0;
}
int n;
int in[SIZE],out[SIZE];

int main()
{
	int i;
	scanf("%d",&n);
	for(i = 0;i < n;i++)
		in[i] = out[i] = 0;
	int a=1,b;
	while(1)
	{
		scanf("%d%d",&a,&b);
		if((a==0)&&(b==0))
			break;
		out[a]++;
		in[b]++;
	}
	for(i = 0;i < n;i++)
		if((in[i] == n-1)&&(out[i] == 0))
		{
			printf("%d\n",i);
			return 0;
		}
}
int sum[M][2];

int main()
{
    int n, i,j;
    scanf("%d", &n);
    while (scanf("%d%d", &i, &j)!=EOF) {
	sum[i][0] ++;
	sum[j][1] ++;
    }
    for (i=0; i<n; i++) {
	if (sum[i][1] - sum[i][0] == n-1) {
	    printf("%d\n", i);
	    return 0;
	}
    }
    /* not found */
    printf("NOT FOUND\n");
    return 0;
}
int main(){
	int n;
	int a[10010],b[10010];
	int p,q;
	cin>>n;
	cin>>p>>q;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	while(p!=0 || q!=0){
		a[p]++;
		b[q]++;
		cin>>p>>q;
	}
	int i;
	for(i=0;i<n;i++){
		if(a[i])
			continue;
		else{
			if(b[i] == n-1){
				cout<<i<<endl;
			}break;
		}
	}return 0;
}
main()
{
      int n,i,j,k,a,b,m=0;
      scanf("%d",&n);
      int**p=(int**)malloc(n*sizeof(int*));
      for(i=0;i<n;i++)
      p[i]=(int*)malloc(2*sizeof(int));
      for(i=0;i<n;i++)
      for(j=0;j<2;j++)
      p[i][j]=0;
      for(k=0;;k++)
      {
             scanf("%d %d",&a,&b);
             if(a==0&&b==0)
             break;
             p[a][0]++;
             p[b][1]++;
      } 
      for(i=0;i<n;i++)
      if(p[i][0]==0&&p[i][1]==n-1)
      {
               printf("%d",i);
               m++;
      }
      if(m==0)
      printf("NOT FOUND");
      for(i=0;i<n;i++)
      free(p[i]);
      free(p);
      getchar();
      getchar();
      getchar();
}
//?????????
//??????
//???2010.12.11

//????????????????????????????????


int main()
{
	int n = 0;
	int num1[100000];
	int num2[100000];
	int flag[100000];     //????flag????????????????
	int except[100000];   //????except??????????????????
	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]]++;
		}
		for (p = 0; p < n; p++)        //?????????
			sum += flag[p];
		if (sum == n - 1)              //?????????n - 1???
		{
			cout << j;
			f = 1;
		}
	}
	if (f == 0)
		cout << "NOT FOUND";

	return 0;
}
int main()
{
	int n,a,b,m=0,s=0,t,i=0,c[10000],d[10000];
	scanf("%d",&n);
	for(a=0;a<n;a++)
	{
		c[a]=0;
		d[a]=0;
	}
	scanf("%d%d",&a,&b);
	while(a!=0||b!=0)
	{
		c[a]++;
		d[b]++;
		scanf("%d%d",&a,&b);
	}
	for(s=0;s<n;s++)
	{
		if(c[s]==0&&d[s]==n-1){printf("%d",s);i=1;break;}
	}
	if(i==0)printf("NOT FOUND");
	return 0;
}
main()
{
      int i,j,n,m=0;
      scanf("%d",&n);
      int a[2][n];
      for(i=0;i<n;i++){a[0][i]=0;a[1][i]=0;}
      for(;;){
      scanf("%d %d",&i,&j);
      if(i==0&&j==0){break;}
      else
      a[0][i]++;
      a[1][j]++;}
      for(i=0;i<n;i++){
      if(a[0][i]==0&&a[1][i]==(n-1)){
      printf("%d",i);m++;}}
      if(m==0)printf("NOT FOUND");
}
int main()
{
	int n,i,j,sum,d,e,temp,amount,f;
	f=0;
	sum=0;
	scanf("%d",&n);
	int a[20000],b[20000];
	for(i=0;i<19000;i++)
	{
		scanf("%d%d",&d,&e);
		a[i]=d;
		b[i]=e;
		sum++;
		if(d==0&&e==0)
		{
			break;
		}
	}
	for(j=0;j<n;j++)
	{
		temp=0;
		amount=0;
		for(i=0;i<sum-1;i++)
		{
			if(j==a[i])
			{
				temp++;
			}
			if(j==b[i])
			{
				amount++;
			}
		}
		if(temp==0&&amount==n-1)
		{
			printf("%d",j);
			f++;
		}
	}
	if(f==0)
	{
		printf("NOT FOUND");
	}
	return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int a[100000],b[100000],c[100000],d[100000];
	memset(c,0,sizeof(c));
	memset(d,0,sizeof(d));
	int i;
	for(i=0;;i++)
	{
		scanf("%d %d\n",&a[i],&b[i]);
		if((a[i]==0)&&(b[i]==0))
			break;
		c[a[i]]=1;
		d[b[i]]++;
	}
	for(i=0;i<n;i++)
	{
		if((c[i]==0)&&(d[i]==n-1))
			printf("%d\n",i);
	}
}
main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    a[i]=0;
    for(int j=0;;j++)
    {
        int p,q;
        scanf("%d %d",&p,&q);
        if((p==0)&&(q==0))
        break;
        else
        {
            a[q]++;
            a[p]--;
        }
    }
    int m;
    for(m=0;m<n;m++)
    {
        if(a[m]==n-1)
        {
        printf("%d",m);
        break;
        }
    }
    if(m==n)
    printf("NOT FOUND");
}
int main()
{
    int max(int a[],int k);
    int n,i[65535],j[65535],m,k,s,t,p;
    int a[65535]={0};
    p=0;
    scanf("%d",&n);
    for(s=0;s<n*(n-1)/2;s++)
        {
            scanf("%d %d",&i[s],&j[s]);
            if(i[s]==0&&j[s]==0)
                break;
        }
    for(t=0;t<n;t++)
        {
            for(k=0;k<s;k++)
                {
                    if(j[k]==t)
                       a[t]=a[t]+1;
                }
        }
    for(k=0;k<n;k++)
        {
            if(a[k]==n-1)
                {
                       m=k;
                       p=1;
                       break;
                }
        }
    if(p==0)
        printf("NOT FOUND");
    else
        {
            for(k=0;k<s;k++)
                {
                    if(i[k]==m)
                        {
                               p=0;
                               break;
                        }
                }
            if(p==0)
                printf("NOT FOUND");
            else
                printf("%d",m);
        }
    getchar();
    getchar();
}
int main ()
{
int n, i = 0,j, flag = 0, tempa,tempb;
int a[100000] = {0}, b[100000] = {0};

cin >> n;
while(cin >> tempa >> tempb)
{
if(tempa == 0 && tempb == 0)
break;
b[tempb] ++;
a[tempa] ++;
}
for(i = 0;i < n;i ++)
{
if( b[i] == n - 1 && a[i] == 0)
cout << i << endl;
flag = 1;
}
if(flag == 0)
cout << "NOT FOUND" << endl;
return 0;
}
struct person
{
	int kn;
	int bkn;
};
main()
{
	int n,a,b,i;
	struct person *p;
	scanf("%d",&n);
	p=(struct person *)malloc(n*sizeof(struct person));
	for (i=0;i<n;i++)
	{
		p[i].kn=0;
		p[i].bkn=0;
	}
	while (1)
	{
		scanf("%d %d",&a,&b);
		if (a==0 && b==0)
			break;
		p[a].kn++;
		p[b].bkn++;
	}
	for (i=0;i<n;i++)
	{
	    if (p[i].kn==0 && p[i].bkn==n-1)
			printf("%d\n",i);
	}
	free(p);
}
int main()
{
    int a[10000],b[10000],i,j,c,d,u,sum,n;
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    while(1)
    {
           scanf("%d%d",&c,&d);
           if(c==0&&d==0)
           {
                         break;
           }
           a[d]++;
           b[c]++;
    }
    sum=0;
    for(i=0;i<n;i++)
    {
                    if(a[i]==n-1&&b[i]==0)
                    {
                                          printf("%d",i);
                                          sum++;
                    }
    }
    if(sum==0)
    printf("NOT FOUND");
    scanf("%d",&u);
    return 0;
}
int main()
{
	int a[10000],b[10000];
	int n;
	int i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		a[i]=b[i]=0;
	}
	while(cin>>i>>j)
	{
		if(i==0&&j==0) break;
		b[i]=1;
		a[j]++;
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==0&&a[i]==n-1) 
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}
struct ming
{
       int n;
       int m;
       struct ming *next;
}; 

struct ming*creat()
{
       struct ming *head,*p1,*p2;
       int i=0;
       p1=p2=(struct ming*)malloc(LEN);
       scanf("%d%d",&p1->n,&p1->m);
       head=NULL;
       while(p1->n!=0||p1->m!=0)
       {
                                i++;
                                if(i==1){head=p1;}
                                else 
                                p2->next=p1;
                                p2=p1;
                                p1=(struct ming*)malloc(LEN);
                                scanf("%d%d",&p1->n,&p1->m);
                                //printf("%d %d\n",p1->n,p1->m);
       }
       p2->next=NULL;
       return(head);
}
int found(int l,struct ming*head)
{
    int i=0;
    struct ming *p1;
    p1=head;
    while(p1!=NULL)
    {
                         if(p1->m==l)
                         {i++;
                         //printf("%d\n",p1->n);
                         }
                         p1=p1->next;
                         //printf("%d %d\n",p1->n,p1->m);
    }
    return(i);
}
 
int main()
{
    int a[100][100];
    int n,o,k,p;
    scanf("%d",&n);
    struct ming *head;
    head=creat();
    for(o=0,k=0;o<n;o++)
    {
                    p=found(o,head);
                    //printf("%d\n",p);
                    if(p==n-1)
                    {
                            printf("%d\n",o);
                            k++;}
    }
    if(k==0)printf("NOT FOUND");
    getchar();
    getchar();
    getchar();
}
/*
 * ?n???????????????????????????????
????????????????????????????????????????????
????????O(n)????

????
?????????n?????n????
????????i?j???i??j???0?i,j<n?
???????0 0????????

????
????????????????????????NOT FOUND?
 *
 */

int main()
{
	int n,i,j,k,number,ju=0;
	int a[100000],b[100000],num[100000];
	cin>>n;
	i=0;
	do{
		cin>>a[i]>>b[i];
		i++;
	}
	while(a[i-1]!=0||b[i-1]!=0);
	number=i-1;
	for(k=0;k<n;k++){
		num[k]=0;
		for(j=0;j<number;j++){
			if(b[j]==k)
				num[k]++;
		}
	}
	for(i=0;i<n;i++){
		if(num[i]==n-1){
			cout<<i<<endl;
			ju++;
		}
	}
	if(ju==0)
		cout<<"NOT FOUND"<<endl;
	return 0;
}
/**
* @file homework.cpp
* @author ??
* @date 2010?11?09
* @description 
* ??????:??????  
*/
int a[9000][9000]={0};
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 (a[i][j]==1)
				g++;
		}
		if (g == n-1)
		{
			cout << j;
			flag =1;
			break;
		}
	}
	if (flag == 0)
		cout << "NOT FOUND";
	return 0;
}
main()
{
      int n,m,f,k=0;
      scanf("%d",&n);
      int a[n],b[n];
      for(int i=0;i<n;i++)
      {a[i]=0;
      b[i]=0;}
      for(int i=0;;i++)
      {scanf("%d %d",&m,&f);
      if(m==0&&f==0) break;
      a[m]++;
      b[f]++;}
      for(int i=0;i<n;i++)
      if(a[i]==0&&b[i]==n-1) {printf("%d\n",i);k++;}
      if(k==0) printf("NOT FOUND\n");
      getchar();getchar();
      }
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],b[n];
    int i,j,k;
    for (i=0;i<n;i++)
    {
        a[i]=0;
        b[i]=0;
    }
    scanf("%d %d",&i,&j);
    while (i!=0 || j!=0)
    {
          a[i]=a[i]+1;
          b[j]=b[j]+1; 
          scanf("%d %d",&i,&j);
    }
    k=0;
    for (i=0;i<n;i++)
        if (a[i]==0 && b[i]==n-1)
        {
          printf("%d",i);
          k=k+1;
        }
    if (k==0) printf("NOT FOUND");
    getchar();
    getchar();
}
int main()
{
	int a[100000] = { 0 };
	int x , y;
	int num[10000] = { 0 };
	int n, k;
	cin >> n;
	int i = 0;
	int j;
	int count = 0;
	cin >> x >> y;
	do
	{
		a[i] = x;
		num[y] ++;
		i ++;
		cin >> x >> y;
	}while( !(x == 0 && y == 0 ) );
	j = i;
	for( i = 0; i < n; i ++)
	{
		if( num[i] == n - 1 )
		{
			for( k = 0 ; k < j; k ++)
			{
				if( a[k] == i)
					break;
				if( k == j - 1)
				{
					cout << i << endl;
					count++;
				}
			}
		}
	}
	if( count == 0 )
		cout << "NOT FOUND" << endl;
	return 0;
}
main()
{
      int n,bei[10000]={0},renshi[10000]={0},i,x,y,k=0;
      scanf("%d",&n);
      for(;;)
      {
             scanf("%d%d",&x,&y);
             if(x==0&&y==0){break;}
             bei[y]++;
             renshi[x]++;
      }
      for(i=0;i<n;i++)
      {
           if(bei[i]>=(n-1)&&renshi[i]==0)
           {printf("%d",i);k++;}
      }
      if(k==0 )
      {printf("NOT FOUND");}
}
int a[maxn];
int main()
{
	int n,i,x1,x2;
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	for (i=0;;i++) {
		scanf("%d %d",&x1,&x2);
		if (x1+x2==0)
			break;
		if (a[x2]!=-1)
			a[x2]++;
		a[x1] = -1;
	}
	for (i=0;i<n;i++)
		if (a[i] == n-1) {
			cout<<i<<endl;
			return 0;
		}
	cout<<"NOT FOUND"<<endl;

}
main ()
{
	int n,a[100000][2],i,t=0,j,b[10000],c[10000],m=0;
	scanf("%d",&n);
	for(i=1;;i++)
	{
		scanf("%d %d",&a[i-1][0],&a[i-1][1]);
		t=t+1;
		if(a[i-1][0]==0&&a[i-1][1]==0)
        {
			break;
		}
	}
	for(i=1;i<=n;i++)
	{
		b[i-1]=0;
	}
	for(i=1;i<=n;i++)
	{
		c[i-1]=0;
	}
	for(j=0;j<=n-1;j++)
	{
		for(i=1;i<=t-1;i++)
		{
			if(a[i-1][1]==j)
			{b[j]=b[j]+1;}
		}
	}
	for(j=0;j<=n-1;j++)
	{
		for(i=1;i<=t-1;i++)
		{
			if(a[i-1][0]==j)
			c[j]=c[j]+1;
		}
	}
	for(j=0;j<=n-1;j++)
	{
		if(b[j]==n-1&&c[j]==0)
		printf("%d",j);
		m=1;
	}
	if(m==0)
	printf("NOT FOUND");
}
int main()
{
    int n,i,j,a[9999],b[9999],flag;
    for(i=0;i<9999;i++)
    {
        a[i]=0;
        b[i]=0;
    }
    scanf("%d",&n);
    i=1;j=1;
    for(;;)
    {
        scanf("%d %d",&i,&j);
        if(i==0&&j==0) break;
        a[j]++;
        b[i]++;
    }
    flag=0;
    for(i=0;i<n;i++)
    {
        if(a[i]==n-1&&b[i]==0)
        {
         printf("%d\n",i);
         flag=1;
        }
    }
    if(flag=0) printf("NOT FOUND");
}
int main(){
	int n;
	scanf("%d",&n);
	struct asd
	{
		int x,y;
	}
	as[100000];
	int i,j=0;
	for(i=0;;i++)
	{
		scanf("%d%d",&(as[i].x),&(as[i].y));
		if(as[i].x==0&&as[i].y==0)
			break;
		j++;
	}
	int g=0;
	for(int t=0;t<n;t++)
	{
		int e=0,f=0;
		for(i=0;i<j;i++)
		{
			if(as[i].x==t)
				e++;
			if(as[i].y==t)
				f++;
		}
		if(e==0&&f==n-1)
		{
			printf("%d",t);
			g++;
		}
	}
	if(g==0)
		printf("NOT FOUND");
	return 0;
	}
struct note
{
	int know;
	int known;
}men[10010];

int main()
{
	int n, i, j, flag = 0;
	cin >> n;
	while(cin >> i >> j)
	{
		if (i == 0 && j == 0)
			break;
		men[i].know++;
		men[j].known++;
	    if (men[j].known == n - 1 && men[j].know != n)
		{
			cout << j;
			flag = 1;
		}
		if (men[i].known == n - 1 && men[i].know != n)
		{
			cout << i;
			flag = 1;
		}
	}
	if (flag == 0)
		cout << "NOT FOUND";
	return 0;
}
int main()
{
	int n;
	cin >> n;
	int take[10000];
	int check[10000];
	for (int p = 0; p < n; p++)
	{
		take[p] = 0;
		check[p] = 0;
	}
	int i, j;
	while(1)
	{
		cin >> i >> j;
		if (i == 0 && j == 0)
			break;
		else
		{
			take[i] = 1;
			check[j]++;
		}
	}
	int flag = 0;
	for (int k = 0; k < n; k++)
	{
		if (take[k] == 0 && check[k] == n - 1)
		{
			cout << k << endl;
			flag = 1;
		}
	}
	if (flag == 0)
		cout << "NOT FOUND" << endl;
	return 0;
}
int a[10010][10010];
int main()
{
	int n,i,j,flag=0;
	cin>>n;
	cin>>i>>j;
	while(i>0||j>0){	
		a[i][j]=1;
		cin>>i>>j;
	}
	for(int i=0;i<n;i++){
		double s=0,t=0;
		for(int j=0;j<n;j++){
			s+=a[i][j];
			t+=a[j][i];
		}
		if(s==0&&t==n-1){
			cout<<i<<endl;
			flag=1;
			break;
		}
	}
	if(!flag)
		cout<<"NO FOUND"<<endl;
	return 0;
}
main()
{
      int i,j,n;
      int a[2][10000]={0};
      scanf("%d",&n);
      scanf("%d %d",&i,&j);
      while(i!=0 || j!=0)
      {
          a[0][i]++;
          a[1][j]++;
          scanf("%d %d",&i,&j);       
      }
      for(i=0;i<n;i++)
      {
          if(a[0][i]==0 && a[1][i]==n-1)
          {
              printf("%d",i);
              break;          
          }            
      }
      if(i==n) printf("NOT FOUND");
}
main()
{
      int k=0,p=0,m=0,n,i,j,a[100000],b[100000],c[100000];
      scanf("%d",&n);
      for(i=0;i<100000;i++)
      {
                        c[i]=0;
      }
      scanf("%d %d",&a[0],&b[0]);
      for(i=1;(a[i-1]!=0)||(b[i-1]!=0);i++)
      {
                      scanf("%d %d",&a[i],&b[i]);
                      k++;
      }
      for(j=0;j<n;j++)
      {
                      for(i=0;i<k;i++)
                      {
                                      if(b[i]==j)
                                      c[j]++;
                      }
      }
      for(j=0;j<n;j++)
      {
                      for(i=0;i<k;i++)
                      {
                                      if(a[i]==j)
                                      break;
                                      else
                                      m++;
                      }
                      if((c[j]==n-1)&&(m==k))
                      {
                                   printf("%d",j);
                                   p++;
                                   break;
                      }
                      m=0;
      }
      if(p==0)
      printf("NOT FOUND");
}
int main()
{
	int n,i;
	cin>>n;
	int a[100000][2];
	memset(a,0,sizeof(a));
	int b[n];
	memset(b,0,sizeof(b));
	for(i=0;;i++)
	{
		cin>>a[i][0]>>a[i][1];
		if(a[i][0]==0&&a[i][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, a, b, max, maxone;
	int person[99999] = {0};
	cin >> n;
	max = 0;
	maxone = -1;
	while (cin >> a >> b)
	{
		if (a == 0 && b == 0)
			break;
		person[b] ++;
		if (person[b] > max)
		{
			max = person[b];
			maxone = b;
		}
	}
	if (max == n - 1)
		cout << maxone << endl;
	else
		cout << "NOT FOUND" << endl;
	return 0;
}
main()
{
      int n;
      scanf("%d",&n);
      int *a=(int *)malloc(n*sizeof(int));
      
      int k,i,j;
      for(k=0;k<n;k++)
      {a[k]=0;}
      for(k=0;;k++)
      {
                   scanf("%d %d",&i,&j);
                   if(i==0&&j==0) break;
                   else
                   {
                       a[i]-=1;
                       a[j]+=1;
                     
                   }
      }
      for(k=0;k<n;k++)
      {
                      if(a[k]==(n-1))
                      {
                                     printf("%d",k);
                                     break;
                                     k=0;
                      } 
      }
      if(k==n) printf("NOT FOUND");
      getchar();
      getchar();
}
int main()
{
int n,a[20000],b[20000],h,i,j,c[10000],d[10000];int k=0;
scanf("%d",&n);
for(h=0;;h++)
{
scanf("%d%d",&a[h],&b[h]);
if(a[h]==0&&b[h]==0)
break;
}
for(i=0;i<n;i++)
{c[i]=1;d[i]=0;}
for(j=0;j<n;j++)
for(i=0;i<h;i++)
if(a[i]==j)
{c[j]=0;break;}
for(j=0;j<n;j++)
if(c[j])
{
for(i=0;i<h;i++)
if(b[i]==j)
d[j]++;
}
for(j=0;j<n;j++)
if(d[j]==n-1&&n>1)
{printf("%d\n",j);k=1;}
if(k==0)
printf("NOT FOUND");}
int main()
{
    int n,i;
    cin>>n;
    int famous[n+1];
    for(i=0;i<n;i++)
   famous[i]=0;
    int a,b;
    while(1)
    {
        cin>>a>>b;
        if(a==0&&b==0)
        break;
        
        famous[b]++;
         
    }
    int m=0;
    for(i=1;i<n;i++)
    {
         if(famous[i]==n-1)
         {
         cout<<i;
         m++;                  
         }
    }
    if(m==0)
    cout<<0<<endl;
    return 0;
    
}
main()
{
int n,a[300000],i,j,k,b[300000];
scanf("%d\n",&n);
for(i=1;i<n+1;i++)
{a[i-1]=i;
b[i-1]=0;}
scanf("%d %d\n",&k,&j);
for(;!(k==0&&j==0);)
{
a[k]=0;
b[j]++;
scanf("%d %d\n",&k,&j);
}
int f=1;
for(i=0;i<n;i++)
{
 if(a[i]!=0&&b[i]==n-1)
 {
 printf("%d\n",a[i]-1);
 f=0;
 }
}
if (f==1)
printf("Not Found");
getchar();getchar();
}
main()
{
	int n,a,b,i,flg=1;                                   //flg??????????????????0?????1 
	int num[MAX];                                        //num???????????????? 
	scanf("%d",&n);
	for (i=0;i<n;i++)                                    //??????????0 
		num[i]=0;
	while (1)
		{scanf("%d %d",&a,&b);                          
		if (a==0 && b==0)                               //?0 0????????
			break;
		else
			num[b]=num[b]+1;
		}
	for (i=0;i<n;i++)
		if (num[i]==n-1)                              //??n-1????????????????? 
			{printf("%d",i);
			flg=0;
			break;}
	if (flg)
		printf("NOT FOUND");	
}
main()
{
    int i,j,n;
    scanf("%d",&n);
    int *p=(int *)malloc(2*n*sizeof(int));
    for(i=0;i<n;i++)
    {
        p[i]=0;
    }
    for(i=1,j=1;i!=0||j!=0;)
    {
        scanf("%d %d",&i,&j);
        p[j]++;
    }
    for(i=0,j=0;i<n;i++)
    {
        if(p[i]==(n-1))
        {
            printf("%d\n",i);
            j=1;
        }
    }
    if(j!=1)
    {printf("NOT FOUND\n");}
}
main()
{
  int n,m=0,i,j;
  scanf("%d",&n);
  int *a=(int *)malloc(n*sizeof(int));
  int *b=(int *)malloc(n*sizeof(int));
  int *c=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++)
  {
    a[i]=i;
    b[i]=0;
    c[i]=0;
  }
  int p[100000][2];
  for(i=0;;i++)
  {
    scanf("%d %d",&p[i][0],&p[i][1]);
    if((p[i][0]==0)&&(p[i][1]==0))
      break;
  }
  int k=i;
  for(i=0;i<k;i++)
  {
      for(j=0;j<n;j++)
      {
        if (p[i][1]==a[j])
          b[j]++;
      }
  }
  for(i=0;i<k;i++)
  {
      for(j=0;j<n;j++)
      {
        if (p[i][0]==a[j])
          c[j]++;
      }
  }
  for(j=0;j<n;j++)
  {
      if((b[j]==n-1)&&(c[j]==0))
      {
        printf("%d\n",j);
        m=1;
      }
  } 
  if(m==0)
    printf("NOT FOUND\n");
    free(a);
    free(b);
    free(c);
  getchar();
  getchar(); 
}