semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int m,n,i,j,h[20][20];
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d",&h[i][j]);
		}
	}
	if(h[0][0]>=h[1][0]&&h[0][0]>=h[0][1])
			printf("0 0\n");
	for(j=1;j<n-1;j++){
		if(h[0][j]>=h[0][j-1]&&h[0][j]>=h[1][j]&&h[0][j]>=h[0][j+1])
				printf("0 %d\n",j);
	}
	if(h[0][n-1]>=h[1][n-1]&&h[0][n-1]>=h[0][n-2])
			printf("0 %d\n",n-1);
	for(i=1;i<m-1;i++){
        if(h[i][0]>=h[i-1][0]&&h[i][0]>=h[i+1][0]&&h[i][0]>=h[i][1])
			     	printf("%d 0\n",i);
		for(j=1;j<n-1;j++)
		{
			if(i>0&&j>0&&i<m-1){ 
		        if(h[i][j]>=h[i-1][j]&&h[i][j]>=h[i][j-1]&&h[i][j]>=h[i+1][j]&&h[i][j]>=h[i][j+1])
			     	printf("%d %d\n",i,j);
			}
		}
		if(h[i][n-1]>=h[i-1][n-1]&&h[i][n-1]>=h[i][n-2]&&h[i][n-1]>=h[i+1][n-1])
			     	printf("%d %d\n",i,n-1);
	}
	if(h[m-1][0]>=h[m-1][1]&&h[m-1][0]>=h[m-2][0])
		printf("%d 0\n",m-1);
	for(j=1;j<n-1;j++){
		if(h[m-1][j]>=h[m-2][j]&&h[m-1][j]>=h[m-1][j-1]&&h[m-1][j]>=h[m-1][j+1])
			     	printf("%d %d\n",m-1,j);
	}
	if(h[m-1][n-1]>=h[m-1][n-2]&&h[m-1][n-1]>=h[m-2][n-1])
		printf("%d %d\n",m-1,n-1);
	return 0;
}
int main(){
	int m,n;
	cin>>m>>n;
	int hill[m+2][n+2];
	for(int i=0;i<(m+2)*(n+2);i++){
		hill[0][i]=0;
	}

	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			cin>>hill[i][j];
		}
	}

	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(hill[i][j]>=hill[i+1][j]&&
					hill[i][j]>=hill[i-1][j]&&
					hill[i][j]>=hill[i][j+1]&&
					hill[i][j]>=hill[i][j-1]){
				cout<<i-1<<' '<<j-1<<endl;
			}
		}
	}
}
void main()
{
	int a[21][21],m,n,i,j;
	scanf("%d %d\n",&m,&n);
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			scanf("%d",&a[i][j]);
		if(a[0][0]>a[0][1]&&a[0][0]>a[1][0])
		printf("0 0\n");
	for(j=0;j<m+1;j++)
		a[j][n]=0;
	for(j=0;j<n+1;j++)
		a[m][j]=0;
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
		{
			if(i==0&&j==0)
				continue;
			if(j==0)
			{
				if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
					printf("%d %d\n",i,j);
			}
			else if(i==0)
				{
				if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])
					printf("%d %d\n",i,j);
			}
			else if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i][j-1])printf("%d %d\n",i,j);
		}
}
int main()
{
	int n,m,num[30][30],cnt=0;
	cin>>m>>n;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		cin>>num[i][j];
	}
	for(int j=1;j<=n;j++)
		num[0][j]=num[1][j];
	for(int i=1;i<=m;i++)
	{
		num[i][0]=num[i][1];
		num[i][n+1]=num[i][n];
	}
	for(int j=1;j<=n;j++)
		num[m+1][j]=num[m][j];
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
			{
				int word=0;
			{
				word+=(num[i-1][j]<=num[i][j]);
			    word+=(num[i+1][j]<=num[i][j]);
			    word+=(num[i][j-1]<=num[i][j]);
			    word+=(num[i][j+1]<=num[i][j]);
		    }
			if(word==4) cout<<i-1<<" "<<j-1<<endl;
	}
	}
	return 0;
}
int main()
{
	int m, n, i, j;
	int a[20][20];
	cin >> m >> n;
	for (i = 0 ; i < m ; i++)
	{
		for (j = 0 ; j < n ; j++)
		{
			cin >> a[i][j];
		}
	}
	for (i = 0 ; i < m ; i++)
	{
		for (j = 0 ; j < n ; j++)
		{
			if (i - 1 >= 0)
			{
				if (a[i - 1][j] > a[i][j])
				continue;
			}
			if (i + 1 < m)
			{
				if (a[i + 1][j] > a[i][j])
				continue;
			}
			if (j - 1 >= 0)
			{
				if (a[i][j - 1] > a[i][j])
				continue;
			}
			if (j + 1 < n)
			{
				if (a[i][j + 1] > a[i][j])
				continue;
			}
			cout << i << " " << j << endl;
		}
	}
	return 0;
}
void main()
{
	int m,n,i,j,x[21][21];
	scanf("%d%d",&m,&n);
	for(i=0;i<21;i++)
		for(j=0;j<21;j++)
		{
			x[i][j]=0;
		}
	for(i=1;i<m+1;i++)
		for(j=1;j<=n;j++)
			scanf("%d",&x[i][j]);

		for(i=1;i<=m;i++)
			for(j=1;j<=n;j++)
			{
				if((x[i][j]>=x[i-1][j])&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i][j+1])&&(x[i][j]>=x[i+1][j]))
					printf("%d %d\n",i-1,j-1);
			}
}
int main()
{
   int n,m,j,i,jz[20][20];
   scanf("%d %d",&m,&n);
   for(i=0;i<m;i++)
   {
      for(j=0;j<n;j++)
      {
         scanf("%d",&jz[i][j]);
      }
   }
   for(i=0;i<m;i++)
   {
      for(j=0;j<n;j++)
      {
         if(i==0&&j==0)
         {
             if(jz[i][j]>=jz[i][j+1]&&jz[i][j]>=jz[i+1][j])
             {
                 printf("%d %d\n",i,j);
             }
         }
         if(i==0&&j!=0&&j!=n-1)
         {
             if(jz[i][j]>=jz[i][j-1]&&jz[i][j]>=jz[i+1][j]&&jz[i][j]>=jz[i][j+1])
                {
                  printf("%d %d\n",i,j);
                }
         }
         if(i==0&&j==n-1)
         {
             if(jz[i][j]>=jz[i][j-1]&&jz[i][j]>=jz[i+1][j])
             {
                  printf("%d %d\n",i,j) ;
             }
         }
         if(i!=0&&i!=m-1&&j==0)
         {
             if(jz[i][j]>=jz[i][j+1]&&jz[i][j]>=jz[i+1][j]&&jz[i][j]>=jz[i-1][j])
             {
                   printf("%d %d\n",i,j);
             }
         }
         if(i!=0&&i!=m-1&&j!=0&&j!=n-1)
         {
              if(jz[i][j]>=jz[i][j+1]&&jz[i][j]>=jz[i+1][j]&&jz[i][j]>=jz[i][j-1]&&jz[i][j]>=jz[i-1][j])
              {
                   printf("%d %d\n",i,j);
              }
         }
         if(i!=0&&i!=m-1&&j==n-1)
         {
              if(jz[i][j]>=jz[i][j-1]&&jz[i][j]>=jz[i+1][j]&&jz[i][j]>=jz[i-1][j])
              {
                   printf("%d %d\n",i,j);
              }
         }
         if(i==m-1&&j==0)
         {
              if(jz[i][j]>=jz[i][j+1]&&jz[i][j]>=jz[i-1][j])
              {
               printf("%d %d\n",i,j);
              }
         }
         if(i==m-1&&j!=0&&j!=n-1)
         {
              if(jz[i][j]>=jz[i][j+1]&&jz[i][j]>=jz[i][j-1]&&jz[i][j]>=jz[i-1][j])
              {
                   printf("%d %d\n",i,j);
              }
         }
         if(i==m-1&&j==n-1)
         {
              if(jz[i][j]>=jz[i-1][j]&&jz[i][j]>=jz[i][j-1])
              {
                   printf("%d %d\n",i,j);
              }
         }
      }
   }	
  return 0;
}
//============================================================================
// Name        : ex6.4.cpp
// Author      : Zhang Yu
// Version     :
// Copyright   : Your copyright notice
// Description : ????
//============================================================================


int main() {
	int height;
	int width;
	cin >>height>>width;
	int a[height][width];
	for (int i=0;i<=height-1;++i)
		for (int j=0;j<=width-1;++j)
			cin >>a[i][j];
	int mountain[100][2];//???????????
	int sum=0;
	for (int i=0;i<=height-1;++i)//???????
		for (int j=0;j<=width-1;++j)//???????
		{
			if (i<=height-2)
			{
				if (a[i][j]<a[i+1][j])
					continue;
			}
			if (i>=1)
			{
				if (a[i][j]<a[i-1][j])
					continue;

			}
			if (j>=1)
			{
				if (a[i][j]<a[i][j-1])
					continue;
			}
			if (j<=width-2)
			{
				if (a[i][j]<a[i][j+1])
					continue;
			}
			//??i,j???????,????

				mountain[sum][0]=i;//??????
				mountain[sum][1]=j;//??????
				++sum;//??????

		}
	
	cout <<endl;
	for (int i=0;i<=sum-1;++i)//????
		for (int j=i;j<=sum-1;++j)
		{
			if (mountain[i][0]>mountain[j][0])
			{
				int temp1=mountain[i][0];
				int temp2=mountain[i][1];
				mountain[i][0]=mountain[j][0];
				mountain[i][1]=mountain[j][1];
				mountain[j][0]=temp1;
				mountain[j][1]=temp2;
			}
		}
	for (int i=0;i<=sum-1;++i)
		cout <<mountain[i][0]<<" "<<mountain[i][1]<<endl;

	return 0;
}
int main() {
	int m, n;
	int a[20][20];
	cin >> m >> n;
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++) {
			if (i == 0) {
				if (j == 0 && a[i][j] >= a[i + 1][j] && a[i][j] >= a[i][j + 1])
					cout << i << " " << j << endl;
				else if (j == n - 1 && a[i][j] >= a[i + 1][j] && a[i][j]
						>= a[i][j - 1])
					cout << i << " " << j << endl;
				else if (a[i][j] >= a[i][j + 1] && a[i][j] >= a[i][j - 1]
						&& a[i][j] >= a[i + 1][j])
					cout << i << " " << j << endl;
			} else if (j == 0&&i!=m-1) {
				if (a[i][j] >= a[i - 1][j] && a[i][j] >= a[i + 1][j] && a[i][j]
						>= a[i][j + 1])
					cout << i << " " << j << endl;
			} else if (j == n - 1&&i!=m-1) {
				if (a[i][j] >= a[i - 1][j] && a[i][j] >= a[i + 1][j] && a[i][j]
						>= a[i][j - 1])
					cout << i << " " << j << endl;
			} else if (i == m - 1) {
				if (j == 0 && a[i][j] >= a[i - 1][j] && a[i][j] >= a[i][j + 1])
					cout << i << " " << j << endl;
				else if (j == n - 1 && a[i][j] >= a[i - 1][j] && a[i][j]
						>= a[i][j - 1])
					cout << i << " " << j << endl;
				else if (a[i][j] >= a[i][j + 1] && a[i][j] >= a[i][j - 1]
						&& a[i][j] >= a[i - 1][j])
					cout << i << " " << j << endl;
			} else if (a[i][j] >= a[i - 1][j] && a[i][j] >= a[i + 1][j]
					&& a[i][j] >= a[i][j + 1] && a[i][j] >= a[i][j - 1])
				cout << i << " " << j << endl;
		}
	return 0;
}
int a[105][105];
int main()
{
  int m,n,t;
  int i,j;
  scanf("%d%d",&m,&n);
  for(i=0;i<m;i++)
	  for(j=0;j<n;j++)
		  scanf("%d",&a[i][j]);
  for(i=0;i<m;i++)
	  for(j=0;j<n;j++)
	  {
		  t=0;
	    if(a[i][j]>=a[i+1][j] || i+1>=m)
			t++;
		if(a[i][j]>=a[i][j+1] || j+1>=n)
			t++;
		if(a[i][j]>=a[i-1][j] || i-1<0)
			t++;
		if(a[i][j]>=a[i][j-1] || j-1<0)
			t++;
		if(t==4)
			printf("%d %d\n",i,j);
	  
	  }
 return 0;

}
int main(){
    int a[22][22]={0};
    int m,n,i,j,x=0,h[400],s[400];
    scanf("%d %d",&m,&n);
    for(i=1;i<=m;i++){
                     for(j=1;j<=n;j++){
                                      scanf("%d",&a[i][j]);
                     }
    }
    for(i=1;i<=m;i++){
                     for(j=1;j<=n;j++){
                                      if((a[i][j]>=a[i-1][j])&&(a[i][j]>=a[i+1][j])&&(a[i][j]>=a[i][j-1])&&(a[i][j]>=a[i][j+1])){
                                                                                                                                 h[x]=i-1;
                                                                                                                                 s[x]=j-1;
                                                                                                                                 x++;
                                      }
                     }
    }	
    for(i=0;i<x;i++){
                     printf("%d %d\n",h[i],s[i]);                 
    }                
    return 0;
}
int main(int argc, char* argv[])
{
	int m,n;
	scanf("%d %d",&m,&n);
	int h[21][21];
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%d",&h[i][j]);
		}
	}
	for(int k=0;k<m;k++)
	{
		for(int l=0;l<n;l++)
		{
			if((k==0&&l==0)&&(h[0][0]>=h[1][0]&&h[0][0]>=h[0][1]))
			{
				printf("%d %d\n",k,l);
			}
			else if((k==0&&l==n-1)&&(h[0][n-1]>=h[0][n-2]&&h[0][n-1]>=h[1][n-1]))
			{
				printf("%d %d\n",k,l);
			}
			else if((k==m-1&&l==0)&&(h[m-1][0]>=h[m-2][0]&&h[m-1][0]>=h[m-1][1]))
			{
				printf("%d %d\n",k,l);
			}
			else if((k==m-1&&l==n-1)&&(h[m-1][n-1]>=h[m-1][n-2]&&h[m-1][n-1]>=h[m-2][n-1]))
			{
				printf("%d %d\n",k,l);
			}
			else if((k==0&&(l>0&&l<n-1))&&(h[k][l]>=h[k][l-1]&&h[k][l]>=h[k][l+1]&&h[k][l]>=h[k+1][l]))
			{
				printf("%d %d\n",k,l);
			}
			else if((k==m-1&&(l>0&&l<n-1))&&(h[k][l]>=h[k][l-1]&&h[k][l]>=h[k][l+1]&&h[k][l]>=h[k-1][l]))
			{
				printf("%d %d\n",k,l);
			}
            else if((l==0&&(k>0&&k<m-1))&&(h[k][l]>=h[k][l+1]&&h[k][l]>=h[k+1][l]&&h[k][l]>=h[k-1][l]))
			{
				printf("%d %d\n",k,l);
			}
            else if((l==n-1&&(k>0&&k<m-1))&&(h[k][l]>=h[k][l-1]&&h[k][l]>=h[k+1][l]&&h[k][l]>=h[k-1][l]))
			{
				printf("%d %d\n",k,l);
			}
			else if(h[k][l]>=h[k][l-1]&&h[k][l]>=h[k][l+1]&&h[k][l]>=h[k-1][l]&&h[k][l]>=h[k+1][l])
			{
				printf("%d %d\n",k,l);
			}
		}
	}
	return 0;
}
int main()
{
	int m,n,i,j,judge;
	int a[20][20];
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
			scanf("%d",&a[i][j]);
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			judge=1;
			if(i>0)
			{
				if(*(*(a+i-1)+j)>*(*(a+i)+j))
					judge=0;
			}
			if(j>0)
			{
				if(*(*(a+i)+j-1)>*(*(a+i)+j))
					judge=0;
			}
			if(j<n-1)
			{
				if(*(*(a+i)+j+1)>*(*(a+i)+j))
					judge=0;
			}
			if(i<m-1)
			{
				if(*(*(a+i+1)+j)>*(*(a+i)+j))
					judge=0;
			}
			if(judge==1)printf("%d %d\n",i,j);
		}
	}
	return 0;
}
int main()
{
	 int m,n,i,j,a[22][22];
     cin>>m>>n;
	 for(i=1;i<=m;i++)
	 {
		 for(j=1;j<=n;j++)
		 {
			 cin>>a[i][j];
		 }
	 }
     for(i=0;i<=n+1;i++)
		 a[0][i]=0;
     for(i=0;i<=n+1;i++)
		 a[m+1][i]=0;
	 for(i=1;i<=m;i++)
		 a[i][0]=0;
	 for(i=1;i<=m;i++)
		 a[i][n+1]=0;
	 for(i=1;i<=m;i++)
	 {
		 for(j=1;j<=n;j++)
		 {
			 if((a[i][j]>=a[i+1][j])&&(a[i][j]>=a[i-1][j])&&(a[i][j]>=a[i][j+1])&&(a[i][j]>=a[i][j-1]))
				 cout<<i-1<<" "<<j-1<<endl;
		 }
	 }
	 return 0;
}
int main()
{ 
	int m,n,sz[100][100],sz1[100],sz2[100],x=0,y=0,i,j,q,w,e;
	scanf("%d %d",&m,&n);
	for( i=0;i<m;i++)
	{
		for( j=0;j<n;j++)
		{
			scanf("%d",&sz[i][j]);
		}
	}
	for(q=0;q<m;q++)
	{
		for( w=0;w<n;w++)
		{ 
			if(sz[q][w]>=sz[q-1>0?q-1:0][w]&&sz[q][w]>=sz[q+1][w]&&sz[q][w]>=sz[q][w-1>0?w-1:0]&&sz[q][w]>=sz[q][w+1])
			{ 
				sz1[x]=q;sz2[y]=w; x++;y++;
			}
		}
	}
	x-=1;y-=1;
	for(e=0;e<=x;e++)
	{
		printf("%d %d\n",sz1[e],sz2[e]);
	}
	return 0;
}
int main()
{
    int height[21][21];
    int m,n;
    cin >> m >> n;
    int i,j,k;
    int sum=0;
    for (i=0;i<m;i++)
    {
        for (j=0;j<n;j++)
        {
            cin >> height[i][j];
            sum += height[i][j];
        }
    }
    
    for (i=0;i<m;i++)
    {
        for (j=0;j<n;j++)
        {
            if (i==0&&j!=0&&j!=n-1)
            {
                if (height[i][j]>=height[i+1][j] && height[i][j]>=height[i][j+1] && height[i][j]>=height[i][j-1])
                {
                    cout << i << " " << j << endl;
                }
            }
            else if(i==m-1&&j!=0&&j!=n-1)
            {
                 if(height[i][j]>=height[i-1][j] && height[i][j]>=height[i][j+1] && height[i][j]>=height[i][j-1])
                 {
                     cout << i << " " << j << endl;
                 }
            } 
            else if(j==0&&i!=0&&i!=m-1)
            {
                 if(height[i][j]>=height[i-1][j] && height[i][j]>=height[i][j+1] && height[i][j]>=height[i+1][j])
                 {
                     cout << i << " " << j << endl;
                 }
            }
            else if(j==n-1&&i!=0&&i!=m-1)
            {
                 if(height[i][j]>=height[i-1][j] && height[i][j]>=height[i+1][j] && height[i][j]>=height[i][j-1])
                 {
                     cout << i << " " << j << endl;
                 }
            }
            else if(j==n-1&&i==0)
            {
                 
                 if( height[i][j]>=height[i+1][j] && height[i][j]>=height[i][j-1])
                 {
                     cout << i << " " << j << endl;
                 }
            }
            else if(j==n-1&&i==m-1)
            {
                 
                 if( height[i][j]>=height[i-1][j] && height[i][j]>=height[i][j-1])
                 {
                     cout << i << " " << j << endl;
                 }
            }
            else if(j==0&&i==0)
            {
                 
                 if( height[i][j]>=height[i+1][j] && height[i][j]>=height[i][j+1])
                 {
                     cout << i << " " << j << endl;
                 }
            }
            else if(j==0&&i==m-1)
            {
                 
                 if( height[i][j]>=height[i-1][j] && height[i][j]>=height[i][j+1])
                 {
                     cout << i << " " << j << endl;
                 }
            }
            else
            {
                 if (height[i][j]>=height[i-1][j] &&height[i][j]>=height[i+1][j] && height[i][j]>=height[i][j+1] && height[i][j]>=height[i][j-1])
                 {
                     cout << i << " " << j << endl;
                 }
            }
        }
    }
   
    return 0;
}
int main(){
    int m,n,i,j;
    scanf("%d %d\n",&m,&n);
    int l[m][n];
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%d",&l[i][j]);
        }
    }
    if(l[0][0]>=l[0][1]&&l[0][0]>=l[1][0]){printf("0 0\n");}
    for(j=1;j<n-1;j++){
        if(l[0][j]>=l[0][j-1]&&l[0][j]>=l[0][j+1]&&l[0][j]>=l[1][j]){
            printf("0 %d\n",j);
        }
    }
    if(l[0][n-1]>=l[0][n-2]&&l[0][n-1]>=l[1][n-1]){printf("0 %d\n",n-1);}
    for(i=1;i<m-1;i++){
        if(l[i][0]>=l[i-1][0]&&l[i][0]>=l[i+1][0]&&l[i][0]>=l[i][1])
            {printf("%d 0\n",i);}
        for(j=1;j<n-1;j++){
            if((l[i][j]>=l[i-1][j])&&(l[i][j]>=l[i+1][j])&&(l[i][j]>=l[i][j-1])&&(l[i][j]>=l[i][j+1])){
                printf("%d %d\n",i,j);
            }
        }
        if(l[i][n-1]>=l[i-1][n-1]&&l[i][n-1]>=l[i+1][n-1]&&l[i][n-1]>=l[i][n-2])
            {printf("%d %d\n",i,n-1);}
    }
    if(l[m-1][0]>=l[m-1][1]&&l[m-1][0]>=l[m-2][0]){printf("%d 0\n",m-1);}
    for(j=1;j<n-1;j++){
        if(l[m-1][j]>=l[m-1][j-1]&&l[m-1][j]>=l[m-1][j+1]&&l[m-1][j]>=l[m-2][j])
            {printf("%d %d\n",m-1,j);}
    }
    if(l[m-1][n-1]>=l[m-1][n-2]&&l[m-1][n-1]>=l[m-2][n-1]){printf("%d %d\n",m-1,n-1);}
    return 0;
}
int main()
{
	int m,n;
	cin >> m >> n;
	int height[200][200];
	int flag[200][200];
	memset(flag, 0, sizeof(flag));
	memset(height, 0, sizeof(height));
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n ;j++)
		{
			cin >> height[i][j];
		}
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
		{
			if (height[i][j] >= height[i - 1][j] && height[i][j] >= height[i + 1][j] && height[i][j] >= height[i][j - 1] && height[i][j] >= height[i][j + 1])
				flag[i][j] = 1;
		}
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
			if (flag[i][j])
				cout << i - 1 << " " << j - 1 << endl;
	return 0;
}
// for each point x, if x has a higher neighbor, set x = -1
// set an extra wall to reduce times of comparison


int main (void)
{
    int i, j, m, n;
    
    scanf ("%i %i", &m, &n);
    int block[m+2][n+2], mark[m+2][n+2];
    //initialize the wall
    for (i = 0; i < n + 2; i++) {
        block[0][i] = -1;
        block[m+1][i] = -1;
    }
    for (i = 1; i < m + 1; i++) {
        block[i][0] = -1;
        block[i][n+1] = -1;
    }
    //read blocks
    for (i = 1; i <= m; i++)
        for (j = 1; j <= n; j++) {
            scanf ("%i", &block[i][j]);
            mark[i][j] = 0;
        }
    for (i = 1; i <=m; i++)
        for (j = 1; j <= n; j++)
            if (mark[i][j] != -1) {
                            if (block[i][j] < block[i][j+1]) {
                                            mark[i][j] = -1;
                                            continue;
                            }
                            else if (block[i][j] > block[i][j+1])
                                 mark[i][j+1] = -1;
                            if (block[i][j] < block[i+1][j]) {
                                            mark[i][j] = -1;
                                            continue;
                            }
                            else if (block[i][j] > block[i+1][j])
                                 mark[i+1][j] = -1;
                            if (block[i][j] < block[i-1][j]) {
                                            mark[i][j] = -1;
                                            continue;
                            }
                            else if (block[i][j] > block[i-1][j])
                                 mark[i-1][j] = -1;
                            if (block[i][j] < block[i][j-1]) {
                                            mark[i][j] = -1;
                                            continue;
                            }
                            else if (block[i][j] > block[i][j-1])
                                 mark[i][j-1] = -1;
                            printf ("%i %i\n", i-1, j-1);
            }
    
    return 0;
}
int n,m;
int area[21][21];
void scan();
void print();
int main(){
    scan();
    print();
    return 0;
}
void scan(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n+2;i++){
        for(int j=0;j<m+2;j++){
        area[i][j]=0;
        }
}
    for(int i=1;i<n+1;i++){
        for(int j=1;j<m+1;j++){
            scanf("%d",&area[i][j]);
        }
    }
}
void print(){
    for(int i=1;i<n+1;i++){
        for(int j=1;j<m+1;j++){
            if((area[i][j]>=area[i-1][j])&&(area[i][j]>=area[i+1][j])&&(area[i][j]>=area[i][j-1])&&(area[i][j]>=area[i][j+1])){
                printf("%d %d\n",i-1,j-1);
            }
        }
    }
}
int main(){
  int m,n,sz[22][22]={0},i,j,a,b;
  scanf("%d%d",&m,&n);
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&sz[i][j]);
    }
   }
  for(a=1;a<=m;a++){
    for(b=1;b<=n;b++){
      if((sz[a][b]>=sz[a-1][b])&&(sz[a][b]>=sz[a+1][b])&&(sz[a][b]>=sz[a][b-  1])&&(sz[a][b]>=sz[a][b+1])){
        printf("%d %d\n",a-1,b-1);
      }
     }
   }
   return 0;
}
int main(){
 int m,n,i,k=0,j;
 int a[20][20];
 scanf("%d%d",&m,&n);
 struct sh
 {
  int m;
  int n;
 }
 sh[400];
 for(i=0;i<m;i++){
  for(j=0;j<n;j++){
   scanf("%d",&a[i][j]);
  }
 }
 if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0]){
  sh[k].m=0;
  sh[k].n=0;
  k++;
 }
 if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1]){
  sh[k].m=0;
  sh[k].n=n-1;
  k++;
 }
 if(a[m-1][0]>=a[m-2][0]&&a[m-1][0]>=a[m-1][1]){
  sh[k].m=m-1;
  sh[k].n=0;
  k++;
 }
 if(a[m-1][n-1]>=a[m-2][n-1]&&a[m-1][n-1]>=a[m-1][n-2]){
  sh[k].m=m-1;
  sh[k].n=n-1;
  k++;
 }
 
 
 for(i=0;i<m;i++){
  for(j=0;j<n;j++){
   if(i==0&&j!=0&&j!=n-1){
    if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]){
     sh[k].m=i;
     sh[k].n=j;
     k++;
    }
    }else if(j==0&&i!=0&&i!=m-1){
     if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j]){
     sh[k].m=i;
     sh[k].n=j;
     k++;
     }
     }else if(j==n-1&&i!=0&&i!=m-1){
      if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]){
     sh[k].m=i;
     sh[k].n=j;
     k++;
      }
     }else if(i==m-1&&j!=0&&j!=n-1){
      if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]){
     sh[k].m=i;
     sh[k].n=j;
     k++;
      }
     }else if(i!=0&&i!=m-1&&j!=0&&j!=n-1){
		 if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j]){
     sh[k].m=i;
     sh[k].n=j;
     k++;
      }
	 }
     
  }
 }
  int e,f;
  for(j=1;j<=k;j++){
   for(i=0;i<k-j;i++){
    if(sh[i].m>sh[i+1].m){
     e=sh[i+1].m;
     f=sh[i+1].n;
     sh[i+1].m=sh[i].m;
     sh[i+1].n=sh[i].n;
     sh[i].m=e;
     sh[i].n=f;
    }
   }
  }
  int c=0;
  i=0;
  for(;c<k;c=i+1){
  for(j=1;j<=k;j++){
	  for(i=c;i<k;i++){
   if(sh[i].m==sh[i+1].m){
	   if(sh[i].n>sh[i+1].n){
		    
            f=sh[i+1].n;
            
            sh[i+1].n=sh[i].n;
            
            sh[i].n=f;
	   }else{
		   continue;
	   }
   }else{
        break;
   }
	  }
  }
  }
  
  for(i=0;i<k;i++){
	  printf("%d %d\n",sh[i].m,sh[i].n);
  }
  return 0;
 }
int main ()
{
	int m,n,s;
	cin >> m >> n;
	int a[20][20];
	int i,j;
	for (i=0;i<m;i++)
	for (j=0;j<n;j++)
	{cin >> a[i][j];}
	for (i=0;i<m;i++)
	for (j=0;j<n;j++)
	{
		s=1;
		if(i-1>=0 && a[i-1][j]>a[i][j])
		{s=0;}
		if(i+1<m && a[i+1][j]>a[i][j])
		{s=0;}
		if(j-1>=0 && a[i][j-1]>a[i][j])
		{s=0;}
		if(j+1<n && a[i][j+1]>a[i][j])
		{s=0;}
		if(s==1)
		{cout<<i<<" "<<j<<endl;}
	}
	return 0;
}
int main()
{
	int m,n,i,j;
	int a[30][30];
	int len[30][30],row[30][30];
	scanf("%d%d",&m,&n);
	for(i=0;i<=m+1;i++)
	{
		for(j=0;j<=n+1;j++)
		{
			a[i][j]=0;
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			len[i][j]=i-1;
			row[i][j]=j-1;
		}
	}
	
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if((a[i][j]>=a[i][j-1])&&(a[i][j]>=a[i][j+1])&&(a[i][j]>=a[i-1][j])&&(a[i][j]>=a[i+1][j]))
			{printf("%d %d\n",len[i][j],row[i][j]);}
		}
	}

	return 0;
}
/*
 * 4.cpp
 *
 *  Created on: 2011-12-27
 *      Author: Administrator
 */
int main()
{
	int a[25][25];
	int m, n, i, j;
	cin >> m >> n;
	for( i = 0; i <= m - 1; i++ )
	{
		for( j = 0; j <= n - 1; j++ )
		{
			cin >> a[i][j];
		}
	}
	for( i = 0; i <= m - 1; i++ )
	{
		for( j = 0; j <= n - 1; j++ )
		{
			if( ( i == 0 || a[i-1][j] <= a[i][j])&&( i == m - 1 || a[i+1][j]<= a[i][j])&&( j == 0 || a[i][j - 1]<= a[i][j])&&(j==n - 1 || a[i][j+1]<=a[i][j]))
				cout << i << " " << j << endl;
		}
	}
	return 0;
}