semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
      int n,i;
      scanf("%d",&n);
      int d1[n];
      int d2[n];
      int a,b;
      a=1;
      b=1;
      for(i=0;i<=n-1;i++)
      {
                       d1[i]=0;
                       d2[i]=0;
      }
      while((a!=0)||(b!=0))
      {
                    
                     a=0;
                     b=0;
                     scanf("%d %d",&a,&b);
                     if((a==0)&&(b==0))
                     break;
                     d2[b]=d2[b]+1;
                     d1[a]=d1[a]+1;
      }
      int m=0;
      for(i=0;i<=n-1;i++)
      {
                       
                       if((d1[i]==0)&&(d2[i]==n-1))
                       {
                                                 printf("%d",i);
                                                 m=1;
                       }
      }
      if(m==0)
      printf("NOT FOUND");
      
}
int main()
{
    int n,i,x,y;
    int a[100000];

    cin>>n;
    for(i=0;i<n;i++) a[i]=1;
    int judge1,judge2;
    cin>>judge1>>judge2;
    if(judge1==0&&judge2==0) {cout<<"NOT FOUND"; return 0;}
    while(judge1!=0||judge2!=0)
    {
        if(judge1==judge2)
        {
            cin>>judge1>>judge2;
            continue;
        }
        else
        {
            a[judge1]=0;
            cin>>judge1>>judge2;
        }
    }
    int num=0,sum=0;

    for(i=0;i<n;i++)
    {
        if(a[i]==1)
        {
            sum++;
            num=i;
        }
    }
    if(sum==0||sum>1) cout<<"NOT FOUND";
    else cout<<num;
    return 0;
}
main()
{
      int n,t,count=0,r;
      scanf("%d",&n);
      int b[10000]={0},c[10000]={0};
      for(t=1;;t++)
      {
            int i,j;
            scanf("%d %d",&i,&j);
            if(i==0&&j==0)
                break;
            else
            {
                b[i]++;
                c[j]++;
            }
      }
      for(r=0;r<n;r++)
      {
            if(b[r]==0&&c[r]==n-1)
            {    
                printf("%d\n",r);
                count++;
            }
      }
      if(count==0)
           printf("NOT FOUND");
}
int main()
{
    int i,n,j=0,*p,*q,a,b;
    scanf("%d",&n);
    p=malloc(n*sizeof(int));
    q=malloc(n*sizeof(int));
    for (i=0;i<n;i++)
    {
        *(p+i)=0;
        *(q+i)=0;
    }
    while (1)
    {
        scanf("%d %d",&a,&b);
        if (a==0&&b==0) break;
        *(p+b)=*(p+b)+1;
        *(q+a)=*(p+a)+1;
    }
    for (i=0;i<n;i++)
    {
        if (*(p+i)==n-1&&*(q+i)==0)
        {printf("%d\n",i);j=1;}
        //printf("%d %d\n",*(p+i),*(q+i));
    }
    if (j==0) printf("NOT FOUND");
}
int main()
{
    int n;
    scanf("%d",&n);
    int m[n],l[n];
    int a[100000],b[100000];
    int i;
    for(i=0;i<100000;i++)
    {
                         scanf("%d %d",&a[i],&b[i]);
                         if(a[i]==0&&b[i]==0) break;
    }
    int j,k=0;
    for(j=0;j<n;j++)
    {
                    m[j]=0;l[j]=0;
                    for(i=0;i<100000;i++)
                    {
                                         if(a[i]==0&&b[i]==0) break;
                                         if(a[i]==j) m[j]++;
                                         if(b[i]==j) l[j]++;
                    }
    }
    for(j=0;j<n;j++)
    {
                   if(m[j]==0&&l[j]==n-1)
                   {printf("%d",j);k=1;}
    }
    if(k==0)
    printf("NOT FOUND");
    getchar();
    getchar();
    
}
/************************* 
??????? 
??????
???2011?12?11? 
*************************/ 

int main()
{
	int n, i = 0, j, k = 0; 
	cin >> n; 
 	int a[100000][2];                               // ??a[i][0]??a[i][1]
	int x[n];                               // ??x[i]?? i ???????
	int y[n];								// ??x[i]???? i ?????
	memset(x, 0, sizeof(x));                           
	memset(y, 0, sizeof(y));      // x, y ??    
	           
	for (i = 0; i < 100000; i++)
	{
		for (j = 0; j < 2; j++)
			cin >> a[i][j];
		if ((a[i][0] == 0) && (a[i][1] == 0))
			break;
		k++;
	}  // ??? 0 0 ???? 
	
	for (i = 0; i < k; i++)
	{
		x[a[i][0]]++;                           
		y[a[i][1]]++;                          
	}
	
	int *p = NULL, *q = NULL; 	// p, q ????? x ?y??? 
	q = y;
	i = 0;  						// i ????? 
	for (p = x; ; p++)
	{
		if (i == n)
		{
			cout << "NOT FOUND";	 // ???????NOT FOUND???? 
			break;
		}
		         
		if ((*p == 0) && (*q == n - 1))  // ?????? 0 ??? n - 1 ????
		{
			cout << i;                       // ????????? 
			break;                            
		} 
		i++; q++;	
	}	          // ???????          
	return 0;
}
main()
{
    int a[10000],b[10000],t,m,n,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        a[i]=0;
        b[i]=0;
    }
    for(;;)
    {
        scanf("%d %d",&m,&n);
        if (m==0&&n==0)
        break;
        a[m]=a[m]+1;
        b[n]=b[n]+1;
    }
    for(i=0;i<t;i++)
    {
        if(a[i]==0&&b[i]==t-1)
        {
            printf("%d",i);
            m++;
        }
    }
    if(m==0)
    printf("NOT FOUND");
}
int main ()
{
	int n,i,j,p[10005];
    cin>>n;
    //if (n!=32&&n!=64&&n!=128&&n!=256&&n!=512)cout<<n;
    if(n==1){cout<<0;return 0;}
    for(i=0;i<n;i++)p[i]=0;
    cin>>i>>j;
    if((i==0)&(j==0)){cout<<"NOT FOUND";return 0;}
    while (!((i==0)&&(j==0)))
    {
		p[i]=-100000;
		p[j]+=i;
		cin>>i>>j;
	}
	for(i=0;i<n;i++)if(p[i]==((n*(n-1)/2)-i)){cout<<i;return 0;}
	cout<<"NOT FOUND";	
    //while(1);
}
int main()
{
    int Ren1,Ren2;
    int i,j,n;
    int value[MAX]={0};
    cin>>n;
    while(1)
    {
        cin>>Ren1>>Ren2;            
            if(!(Ren1==0 && Ren2==0))
            {
              value[Ren1]--;           
              value[Ren2]++;         
            }
           else
           break; 
    }
 
   for(i=0;i<=n-1;i++)
     if(value[i]==n-1)
      { cout<<i;  goto line;}
     cout<<"NOT FOUND"; 
line:
    
 return 0;   
}
int a[10000];
int main()
{
	int tell, n, i, j, k, *p;
	p = a;
    cin >> n;
	for(i = 0; i < n; i++)
		a[i] = 1;
	while(cin >> i >> j)
		if(i != j)
			*(p + i) = 0;
	for(i = 0; i < n; i++)
		if(a[i])
		{
			cout << i << endl;
			break;
		}
	if(i == n)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
    int k, sz[number][2], i, j, mc=0, n, a, b;
	scanf("%d", &n);
	for(i=0;1;i++)
	{
		scanf("%d%d", &a, &b);
		if(a==0&&b==0)
			break;
		else
		{
			sz[a][0]++;
			sz[b][1]++;
		}
	}
    for(i=0;i<n;i++)
	{
		if(sz[i][0]==0&&sz[i][1]==n-1)
		{
			printf("%d\n", i);
			mc++;
		}
	}
	if(mc==0)
		printf("NOT FOUND");
	return 0;
}
main()
{
    int n;
    int i,j,h;
    int t=0;
    int a[100000];
    int b[100000];
    int c[100000]={0};
    int d[100000]={0};
    scanf("%d",&n);
    scanf("%d %d",&a[0],&b[0]);
    i=0;
    while(a[i]!=0||b[i]!=0)
    {
        i++;
        h=i;
        scanf("%d %d",&a[i],&b[i]);
    }
    for(j=0;j<h;j++)
    {
        c[a[j]]++;
    }
    for(j=0;j<h;j++)
    {
        d[b[j]]++;
    }
    for(j=0;j<n;j++)
    {
        if(c[j]==0&&d[j]>=n-1)
        {
            printf("%d",j);
            t=1;
        }
    }
    if(t==0)
    printf("NOT FOUND");
}
int main()
{
    int c,d,e,f,i,n;
    c=0;
    int a[100000],b[100000],p[100000]={0},q[100000]={0};
    scanf("%d",&n);
    for(i=0;i<=(n*(n-1)/2);i++)
    {
                          scanf("%d %d",&a[i],&b[i]);
                          if(a[i]==0&&b[i]==0) 
                          {d=(i-1);}
                          if(a[i]==0&&b[i]==0) break;
    }
    for(i=0;i<=(n-1);i++)
    {
                          for(f=0;f<=d;f++)
                          {
                                 if(a[f]==i)
                                 p[i]=1;
                          }
    }
    for(i=0;i<=(n-1);i++)
    {
                          for(f=0;f<=d;f++)
                          {
                                 if(b[f]==i)
                                 q[i]++;
                          }
    }
    for(i=0;i<=(n-1);i++)
    {
                          if(p[i]==0&&q[i]==(n-1))
                          {printf("%d",i);
                          c=1;}
    }
    if(c==0)
    {printf("NOT FOUND");}
    getchar();
    getchar();
    getchar();
}
int n=0;
int k1=0,k2=0,flag=0;
int sum1[100000];
int sum2[100000];
int main()
{
    //freopen("zozo.in","r",stdin);
    //freopen("zozo.out","w",stdout);
    scanf("%d",&n);
    //if (n==0) {printf("NOT FOUND\n"); return 0; }
    scanf("%d%d",&k1,&k2);
    while (!(k1==0 && k2==0))
    {
     sum1[k1+1]++; sum2[k2+1]++;
     scanf("%d%d",&k1,&k2);
    }
    flag=0;
    for (int i=1; i<=n; i++)
        if (sum1[i]==0)
        {
          if (sum2[i]==n-1)
          {
            flag=1;
            printf("%d\n",i-1);
            break;
          }
        }
    if (flag==0) printf("NOT FOUND\n");
    return 0;
}
int main()
{
     	int n,i,l,k,flag,a[100000],b[100000],c[100000];
		scanf("%d",&n);
		for(i=0;;i++)
		{
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]==0&&b[i]==0)
			{
			    l=i;
			    break;
            }
		}
		for(i=0;i<n;i++)
		{
            c[i]=0;
        }
        for(i=0;i<l;i++)
        {
            k=b[i]-0;
            c[k]++;
         
		}
		for(k=0;k<n;k++)
		{
            flag=0;
	     	if(c[k]==n-1)
	     	{
              flag=1;
              for(i=0;i<l;i++)
              {
				if(a[i]==k)
				{
					flag=0;
					break;
				}
              }
              if(flag==1)
              {
		     	printf("%d",k);
		     	break;
              }
            }
        }
        if(flag==0)
            printf("NOT FOUND");
			
return 0;
}
int k[10000][10000];
int n,a,b,c,i,j,ans;

int main()
{
	scanf("%d",&n);
	while (1)
	{
		scanf("%d%d",&a,&b);
		if (a == 0 && b == 0) break;
		else
			k[a][b] = 1;
	}
	c = 0;
	for (i = 1;i < n;i ++)
		if (k[c][i] == 1) c = i;
	for (i = 0;i < n;i ++)
      if (i != c )
		  if (k[i][c] == 1 && k[c][i] == 0) continue;
		  else break;
    if (i == n) printf("%d\n",c);else printf("NOT FOUND\n");
}
int main()
{
    int n,i,j,c,d,t=0;
    scanf("%d",&n);
    int a[20000]={0};
    int b[20000]={0};
    for(i=0;i<20000;i++)
    {
      scanf("%d %d",&c,&d);
      if((c==0)&&(d==0))
      break;
      a[c]=a[c]-1;
      b[d]=b[d]+1;      
      }
      for(j=0;j<i;j++)
      {
        if((b[j]==(n-1))&&(a[j]==0))
        {printf("%d\n",j);t=1;}
        }
        if(t==0)
        printf("NOT FOUND");
         
              return 0;
              }
//****************************************************** 
//* ? ? ?   ?? ? ? ? ? ?                     *
//* ? ?      ?? ? ?                              *
//* ? ? ? ??2010 ? 12 ? 8 ?                    * 
//* ? ?      ?1000010185                            *
//****************************************************** 
int main()
{
	int a[10000] = {0}, b[10000] = {0}, x, y, n; // ??a[i]??i?????????b[i]??i??????
	cin >> n;
	while (cin >> x >> y)
	{
		if (x == y)
			break;
		a[x] = 1; // x?????
		b[y]++; // y???????1
	}
	int i;
	for (i = 0; i < n; i++)
		if (a[i] == 0 && b[i] == n - 1) // ?i????????n-1???
		{
			cout << i;
			break;
		}
	if (i == n)
		cout << "NOT FOUND";
	return 0;
}
/*???1000012904_5.cpp
  ????????????
  ?????
  ???2010?12?10?
 */
int main()
{
	//???????????????count,?????????beasked,?????????answer?????i,??n,????sum
	int count[100000], beasked[100000], answer[100000], i, n,sum = 0;
	memset(count, 0, sizeof(count));
	cin >> n;
	for(i = 0; i < n * (n - 1); i++)
	{
		cin >> beasked[i] >> answer[i];
		//??0 0 ?????
		if( beasked[i] == 0 && answer[i] == 0)
			break;
		else
			count[answer[i]]++;//answer[i]???????????
		sum++;//?????1
	}
	int flag = 0;
	for(i = 0; i < n; i++)
	{
		int know = 0;//?????????????
		if(count[i] == n - 1 )//???????????
		{
			for(int j = 0; j < sum; j++)
			{
				if(beasked[j] == i)//????????????
					know++;//????????1
			}
			if(know == 0)//??????????
			{
				cout << i << endl;//??????????
				flag =1;//??????
			}
		}
	}	
	if(flag == 0)
		cout <<"NOT FOUND" << endl;//???????????NOT FOUND
	return 0;
}
//******************
//?????????
//?????
//???2011-12-10
//******************
int main()
{
	int *p1 = NULL, *p2 = NULL, a[10000] = {0}, i, j, n;
	int b[100000], c[100000];             
	p1 = b;                 //?b?c??????????p1?p2
	p2 = c;
	cin >> n;          //????
	for(i = 0;;i++)
	{
		cin >> *p1 >> *p2;           
		if(*p1 == 0 && *p2 == 0)         //????0 0?????
			break;
		for(j = 0;;j++)
		{
			if(j == *p2)            //????????????????a????
			{
				a[j]++;
				break;
			}
		}
		p1++;            //???????
		p2++;
	}
	int k = 0;          //k?????????
	for(j = 0;;j++)
	{
		if(a[j] == n - 1)      //??????????
		{
			for(;i > 1;i--)          //??????????????????
			{
				if(*--p1 == j)
					break;
			}
			if(i == 1)          //i=1??????????
			{
				cout << j;        //????????
				k = 1;
				break;
			}
		}
	}
	if(k == 0)         //??????????????
	{
		cout << "NOT FOUND";
	}
	return 0;
}
int main()
{
	int n, m;
	int p, q = 0, r = 0;
	int i = 0, j;
	int a, b, c[10000] = {0}, d[10000] = {0};
	cin >> n;
	while(1)
	{
		cin >> a >> b;
		if(a == 0 && b == 0)
			break;
		c[b]++;
		d[a]++;
		i++;
	}
	for(i = 0; i < n; i++)
	{
		if(c[i] == n - 1)
		{
			if(d[i] == 0)
			{
				cout << i << endl;
				break;
			}
			else
				cout << "NOT FOUND" << endl;
		}
		else
			q++;
	}
	if(q == n)
		cout << "NOT FOUND" << endl;
	return 0;
}
int map[9000][9000];
int main()
{
	int n, i, j;
	int found = 0;
	scanf("%d%d%d", &n,&i,&j);
	while ((i != 0)||(j != 0))
	{
		map[i][j] = 1;
		scanf("%d%d", &i, &j);
	}
	for (i = 0; i < n; i++)
	{
		int mark = 0;
		for (j = 0; j < n; j++)
		{
			if ((map[i][j] == 1)&&(i != j))
			{
				mark = 1;
				break;
			}
		}
		if (mark == 0)
		{
			int mark2 = 0;
			for (j = 0; j < n; j++)
			{
				if ((j != i)&&(map[j][i] == 1))
					mark2++;
			}
			if (mark2 == n-1)
			{
				found = 1;
				printf("%d\n", i);
				break;
			}
		}
	}
	if (found == 0)
		printf("NOT FOUND\n");
	return 0;
}
//??????????
//??????
//?????2011-1-8


int main()
{
    int n,i,j,count[200000]={0},check[200000]={0};
    cin>>n;
    while (true)
    {
          cin>>i>>j;
          if ((i==0)&&(j==0)) break;
          count[j]++;//??j??+1 
          check[i]++;//i????+1 
    }
    for (i=0;i<n;i++) 
      if ((count[i]==n-1)&&(check[i]<n-1)) {cout<<i;return 0;}//?????????? 
    cout<<"NOT FOUND";
    return 0;
}
main()
{
    int a[100000],b[100000],i,n,j,k,t=0,x=0;
    scanf("%d",&n);
    for(i=0;;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==0&&b[i]==0) break; 
        t=t+1;                
    }
    for(i=0;i<t;i++)
    {
        k=0,x=0;            
        for(j=0;j<t;j++)
        {
            if(b[j]==b[i])
            k=k+1; 
            if(a[j]==b[i])
            x=1;               
        } 
        if(k==n-1&&x==0)
        {
        printf("%d",b[i]);
        break;          
        }                
    }
     if(i==t&&k!=n-1)
        printf("NOT FOUND");  
        
}
int main() 
{
	int i, n, x, y;
	int know[10000], beknown[10000];
	for (i = 0; i < 10000; i ++)
	{know[i] = 0; beknown[i] = 0;}
	cin >> n;
	int *p = know;
	int *q = beknown;
	while (1)
	{
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		(*(p + x))++;
		(*(q + y))++;
	}
	int flag = 1;
	for (i = 0; i < n; i ++)
		if (know[i] == 0 && beknown[i] == n - 1)
		{
			flag = 0;
			cout << i << endl;
			break;
		}
	if (flag)
		cout << "NOT FOUND" << endl;
	return 0;
}
int main()
{
    int n,i;
    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;
        }
    }
    int count=0,count0=0;
    for(int l=0;l<n;l++)
    {
        count=count+l;
    }
    for(int j=0;j<n;j++)
    {
        int count1=0,count2=0;
        for(int k=0;k<i;k++)
        {
            if(a[k]==j)
            {
                count1++;
            }
            if(b[k]==j)
            {
                count2=count2+a[k];
            }
        }
        if(count1==0&&count2==count-j)
        {
            printf("%d\n",j);
            count0++;
        }
    }
    if(count0==0)
    {
        printf("NOT FOUND");
    }
    return 0;
}
int main()
{
    int n,i,j,a[100000],b[100000],k,c,u=0,g=0;
    scanf("%d",&n);
    for(i=1;;i++)
    {
                          
                          scanf("%d %d",&a[i],&b[i]);
                          if(a[i]==0&&b[i]==0)
                          break;
                          g++;
    }
    for(j=0;j<=n-1;j++)
    {
                     k=0,c=0; 
                     for(i=1;i<=g;i++)
                     {
                                      if(j==a[i])
                                      k++;
                     }
                     for(i=1;i<=g;i++)
                     {
                                      if(j==b[i])
                                      c++;
                     }
                     if(k==0&&c==(n-1))  //hungry~~~ToT.....
                     {printf("%d",j);
                     u++;
                     }
    }
    if(u==0)
    printf("NOT FOUND");
    getchar();
    getchar();
    getchar();
}
int main()
{
	int n,i,r1,r2,refer=0;
	scanf("%d",&n);
	int *sz=(int*)malloc(sizeof(int)*n);
	int *sz2=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++)
	{
		sz[i]=1;
		sz2[i]=0;
	}
	while(1)
	{
		scanf("%d %d",&r1,&r2);
		if(r1==0 && r2==0)
		{
			break;
		}
		if(r1!=r2)
		{
			sz[r2]++;
			sz2[r1]=1;
		}
	}
	for(i=0;i<n;i++)
	{
		if(sz[i]==n && sz2[i]==0)
		{
			printf("%d",i);
			refer=1;
		}
	}
	if(refer==0)
	{
		printf("NOT FOUND");
	}
	free(sz);
	free(sz2);
	return 0;
}
int main()
{
         int n;
         int x,y,t;
         cin>>n;
         int ans=0;
         int count[n];
         for(int i=0;i<n;i++)count[i]=0;
         while(cin>>x>>y)
         {
                  if(x==0 && y==0){break;}
                  else
                  {
                           count[y]++;
                  }
         }
         for(int i=0;i<n;i++)
         {
                                    if(count[i]==n-1){ans++;t=i;}
         }
         if(ans==1)cout<<t;
         else cout<<"NOT FOUND";
}
main()
{
   int n;
   scanf("%d",&n);
   int *p=(int *)malloc(sizeof(int)*n);
   for(int i=0;i<n;i++)  *(p+i)=0;
   int *t=(int *)malloc(sizeof(int)*n);
   for(int i=0;i<n;i++)  *(t+i)=0;
   int a,b;
    scanf("%d %d",&a,&b);
   while(a!=0||b!=0)
   {
      *(t+a)=*(t+a)+1;
      *(p+b)=*(p+b)+1;
      scanf("%d %d",&a,&b);        
   }
   int y=0;
   for(int i=0;i<n;i++)
   {
      if((*(p+i)==n-1)&&(*(t+i)==0))
      {
         printf("%d",i);
         y=1;                          
      }    
   }
   if(y==0)
     printf("NOT FOUND");
   getchar();
   getchar();
   
}
//****************************************************** 
/* ? ? ?   ???????
/* ? ?      ????                           
/* ? ? ? ??2010 ? 12  ?  13  ?     
/* ? ? ? ??????????????????????
???????????????
/* ? ?      ?1000012752        
*******************************************************/ 
int main()                                  
{
	int biaoji = 1;											//biaoji????????????
	int n;					
	int i,j;
	int a,b;
	int known[10000]={0},know[10000]={0};					//?????????know??????known
	cin >> n;
	for(i=0 ;  ; i++)
	{
		cin >> a >> b;										//????
		if(a==0 && b==0)									//??0?0??
			break;	
		if(a==b && a!=0)
			continue;
		know[a] = 1;										//????0?0????????????????????
		known[b]++;											//??????????
	}
	for(j=0 ; j<n ; j++)					
	{
		if(know[j] == 0 && known[j] == n-1)					//????????????????????n-1???????????
		{
			cout << j << endl;
			biaoji=0;
		}
	}

	if(biaoji)
		cout << "NOT FOUND" <<endl;
                  
    return 0;
}
int people[500000]={0};
int main()
{
	int n;

	int a,b;

	cin>>n;
	while(cin>>a>>b)
	{
		people[a]=-1;
		if (people[b]>=0)
		{
			people[b]++;
			if (people[b]==n-1)
			{
				cout<<b<<endl;
				return 0;
			}

		}
	}

	cout<<"NOT FOUND"<<endl;

	

}

/****************


/****************/
int main()
{
	int n, i, j, a[100000]={0}, b[100000]={0},flag = 0;
	cin >> n;
	cin >> i >> j;
	while(i+j)
	{	
		a[j]++;
		b[i]++;
		cin >> i >> j;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==n-1&&!b[i])
		{
			cout << i << endl;
			flag = 1;
		}
	}
	if(flag == 0)
		cout << "NOT FOUND";
	return 0;

}
int main(){
    int n,i,j,k,l=0,w=0,x[10000],y[10000];
	int s,d;
    scanf("%d",&n);
    for(i=0;i<n*(n+1);i++){
        scanf("%d%d",&x[i],&y[i]);
        w++;
        if(x[i]==0&&y[i]==0)
        break;
        }
    for(k=0;k<n;k++){
        s=0;
		d=0;
        for(i=0;i<w-1;i++){
                if(x[i]==k) s++;
                if(y[i]==k) d++;                               
            }
        if(s==0&&d==n-1){
            printf("%d\n",k);
            l=1;
            } 
        }
     if(l!=1) printf("NOT FOUND");
    return 0;
    }
int a[MAX][MAX]={0};

int main()
{
    int n, i, j, k;
    scanf("%d", &n);
    while(scanf("%d%d", &i,&j)!=EOF &&(i||j))
                        a[i][j]=1;
    
    i=0, j=n-1;
    while(i<j)
    {
              if(a[i][j])
                         i++;
              else j--;
    }
    int flag=0;
    for(k=0; k<n; k++)
    {
             if(a[i][k])
                        flag=1;
             if(!a[k][i]&&k!=i)
                        flag=1;
    }
    if(flag)
            printf("NOT FOUND\n");
    else    printf("%d\n", i);
    return 0;       
}
int  main()
{
     int d,e,f,g,i,j,k,l,m,n,x,y;
     int a[10000]={0};
     int b[10000]={0};
     scanf("%d",&d);
x=y=1;         
a[0]=b[0]=-1;
    while(x+y!=0)
    {
        scanf("%d %d",&x,&y);
        a[x]++;
        b[y]++;
    }
    
     for(j=0,m=1,n=0;j<d;j++)
        {
            if(b[j]==d-1&&a[j]==0)
             {
                      l=j;           
             n=1;
           
            }
            
           
        }                                            
     if(n==1)
       printf("%d",l);
       else
        printf("NOT FOUND");
        
 
}
main()
{
	int n,a[10000],b[10000],i,j;
	scanf("%d",&n);
	while(scanf("%d%d",&i,&j),i||j)
	{
		a[i]++;
		b[j]++;
	}
	for(i=0;i<n;i++)
		if(a[i]==0&&b[i]==n-1)
		{
			printf("%d",i);
			break;
		}
	if(i>=n) printf("NOT FOUND");
}
int main()
{
	int n,a[100000]={0},b[100000]={0},i=0,t=0,j,x=0,y=0,w=0;
	scanf("%d",&n);
	while(scanf("%d %d",&a[i],&b[i])!=EOF&&!(a[i]==0&&b[i]==0))
	i++;
	t=i-1;
	for(i=0;i<n;i++)
	{
		if(w==0)
		{
		for(j=0;j<=t;j++)
		{
			if(i==a[j])
				x++;
		}
		if(x==0)
		{
			for(j=0;j<=t;j++)
			{
				if(b[j]==i)
					y++;
			}
			if(y==n-1)
			{printf("%d\n",i);w++;}
		}
		}
		x=0;
		y=0;
	}
	if(w==0)
		printf("NOT FOUND\n");
	return 0;
}
/*
/???   12(4)
/??     ???
/??     2012?12?11?
/???   ??????
*/
struct person
{
	int x, y;
}p[10001];
int main()
{
	int k, i, j, n;
	cin >> n;
	while(cin >> i >> j && (i != 0 || j != 0))
	{
		p[i].x++;
		p[j].y++;
	}
	for(k = 0; k <= n - 1; k++)
	{
		if(p[k].x == 0 && p[k].y == n - 1)
		{
			cout << k << endl;
		}
	}
	return 0;
}
main()
{
      int n,*a,i,j;
      scanf("%d",&n);
      a=(int *)malloc(sizeof(int)*n);
      memset(a,0,sizeof(int));
      for(;;)
      {
             int x,y;
             scanf("%d %d",&x,&y);
             if(x==0&&y==0){break;}
             a[x]--;
             a[y]++;
      }
      for(i=0;i<=n-1;i++)
      {
             if(a[i]==n-1){printf("%d",i);}
      }   
}
main()
{
      int n,k,i[65534],j[65534],count1[10000]={0},count2[10000]={0},m;
      scanf("%d",&n);
      for(k=0;;k++)
      {        
          scanf("%d %d",&i[k],&j[k]);
          if((i[k]==0)&&(j[k]==0))
          break;
          for(m=0;m<n;m++)
          {
             if(i[k]==m)
             count1[m]++;
             else if(j[k]==m)
             count2[m]++;
          }             
      }
      for(m=0;m<n;m++)
      {
         if((count1[m]==0)&&(count2[m]==n-1))
         {
          printf("%d",m);
          break;
         }
      }
      if(m==n)
      printf("NOT FOUND");
      getchar();
      getchar();
}
struct person
{
	int knownum;
	int welknownnum;
}p[100000];

int main()
{
	int n=0;
	cin>>n;
	int i=0;
	for( i=0; i<n; i++ )
	{
		p[i].knownum=0;
		p[i].welknownnum=0;
	}
	int j=0;
	while(cin>>i>>j)
	{
		if( i==0 && j==0 )
		{
			break;
		}
		else
		{
			p[i].knownum++;
			p[j].welknownnum++;
		}
	}
	for( i=0; i<n; i++ )
	{
		if( p[i].knownum == 0 && p[i].welknownnum == n-1 )
		{
			cout<<i<<endl;
			break;
		}
	}
	if( i==n )
	{
		cout<<"NOT FOUND"<<endl;
	}
}