semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int m,n,A[30][30];
	int i,j;
	scanf("%d%d",&m,&n);
	for(i=0;i<30;i++)
	{
		for(j=0;j<30;j++)
		{
			A[i][j]=0;
		}
	}
	for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;j++)
		{
			scanf("%d",&A[i][j]);
		}
	}
	                         
	for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;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])
				printf("%d %d\n",i-1,j-1);
		}
	}
	return 0;
}
int main()
{
	int a[20][20],m,n,i,j,b[400][2],k=0;
	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++)
		{
			if (i!=0&&j!=0&&i!=m-1&&j!=n-1)
			{
				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])
				{
					b[k][0]=i;
					b[k][1]=j;
					k+=1;
					continue;
				}
			}
			if (i==0)
			{
				if (j==0)
				{
					if (a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
						{
							b[k][0]=i;
							b[k][1]=j;
							k+=1;
							continue;
						}

				}
				else if (j==n-1)
				{
					if (a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
						{
							b[k][0]=i;
							b[k][1]=j;
							k+=1;
							continue;
						}
				}
				else
				{
					if (a[i][j]>=a[i][j+1]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
						{
							b[k][0]=i;
							b[k][1]=j;
							k+=1;
							continue;
						}
				}
			}
			if (i==m-1)
			{
				if (j==0)
				{
					if (a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])
						{
							b[k][0]=i;
							b[k][1]=j;
							k+=1;
							continue;
						}

				}
				else if (j==n-1)
				{
					if (a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
						{
							b[k][0]=i;
							b[k][1]=j;
							k+=1;
							continue;
						}
				}
				else
				{
					if (a[i][j]>=a[i][j+1]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
						{
							b[k][0]=i;
							b[k][1]=j;
							k+=1;
							continue;
						}
				}
			}
			if (j==0)
			{
				if (a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])
					{
						b[k][0]=i;
						b[k][1]=j;
						k+=1;
						continue;
					}
			}
			if (j==n-1)
			{
				if (a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])
					{
						b[k][0]=i;
						b[k][1]=j;
						k+=1;
					}
			}
		}
}
	for (i=0;i<k;i++)
		printf ("%d %d\n", b[i][0], b[i][1]);
	return 0;
}
int main()
{
 int a[25][25],m,n;
 cin>>m>>n;
 for(int i=0;i<25;i++)
   for(int j=0;j<25;j++)a[i][j]=0;
 for(int i=1;i<=m;i++)
   for(int j=1;j<=n;j++)cin>>a[i][j];
 for(int i=1;i<=m;i++)
   for(int 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;      
     }
 cin.get();cin.get();
 return 0;
}
int main()
{
	int i,j,n,m,k,c=-1;
	int sz[N+2][N+2]={0},Hi[N*N],Hj[N*N];
	scanf("%d %d",&m,&n);
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
		 scanf("%d",&sz[i][j]);
		} 
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i][j-1])
			{
                c++;
                Hi[c]=i-1;
                Hj[c]=j-1 ;
			}
		}
	}
    for(k=0;k<c;k++)
	{
       printf("%d %d\n",Hi[k],Hj[k]);
	}
    printf("%d %d",Hi[c],Hj[c]);
	return 0;
}
// ????.cpp : ??????????????
//
//#include "stdafx.h"

const int minn=-10000;
int main()
//int _tmain(int argc, _TCHAR* argv[])
{
	int a[100][100];
	int m,n,sum=0;
	cin>>m>>n;
	for (int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
		{
			cin>>*(*(a+j)+i);
		}
	for(int i=1;i<=n;i++)
	{
		**(a+i)=minn;
		*(*(a+i)+m+1)=minn;
	}
	for(int i=1;i<=m;i++)
	{
		*(*a+i)=minn;
		*(*(a+n+1)+i)=minn;
	}

	for (int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
		{
			if(*(*(a+j-1)+i)-*(*(a+j)+i)<=0&&*(*(a+j+1)+i)-*(*(a+j)+i)<=0&&*(*(a+j)+i-1)-*(*(a+j)+i)<=0&&*(*(a+j)+i+1)-*(*(a+j)+i)<=0)
			cout<<i-1<<' '<< j-1<<endl;
		}
		
	return 0;
}
int main ()
{
int m,n,i,j;
scanf("%d%d",&m,&n);
int sz[NUMBER][NUMBER];
for(i=0;i<=m+1;i++){
	for(j=0;j<=n+1;j++){
		sz[i][j]=0;
	}
}
for(i=1;i<=m;i++){
	for(j=1;j<=n;j++){
		scanf("%d",&(sz[i][j]));
	}
}
for(i=1;i<=m;i++){
	for(j=1;j<=n;j++){
		if(sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i-1][j]){
			printf("%d %d\n",i-1,j-1);
		}
	}
}
return 0;
}
int main()
{
	int h[20][20]={0},m,n,i,j;
	int flag[20][20]={0};
	cin>>m>>n;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>h[i][j];
		}
		
	}


	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i+1>=0&&i+1<m&&h[i+1][j]>h[i][j])
			{
				flag[i][j]=1;
			}

			if(i-1>=0&&i-1<m&&h[i-1][j]>h[i][j])     //
			{
				flag[i][j]=1;
			}

			if(j-1>=0&&j-1<n&&h[i][j-1]>h[i][j])     //
			{
				flag[i][j]=1;
			}

			if(j+1>=0&&j+1<n&&h[i][j+1]>h[i][j])
			{
				flag[i][j]=1;
			}


		}
	}

	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)         //
		{
			if(flag[i][j]==0)
			{
				cout<<i<<" "<<j<<endl;
			}

		}
	}


	return 0;
}
void main()
{
	int m,n,i,j,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++)
			{
				if(i==0)
				{
					if(j==0 && a[i][j]>=a[i][j+1] && a[i][j]>=a[i+1][j]) P;
					else if(j==n-1 && a[i][j]>=a[i][j-1] && a[i][j]>=a[i+1][j]) P;
					else if(a[i][j]>=a[i][j-1] && a[i][j]>=a[i][j+1] && a[i][j]>=a[i+1][j]) P;
				}
				else if(i==m-1)
				{
					if(j==0 && a[i][j]>=a[i][j+1] && a[i][j]>=a[i-1][j]) P;
					else if(j==n-1 && a[i][j]>=a[i][j-1] && a[i][j]>=a[i-1][j]) P;
					else if(a[i][j]>=a[i][j-1] && a[i][j]>=a[i][j+1] && a[i][j]>=a[i-1][j]) P;
				}
				else
				{
					if(j==0 && a[i][j]>=a[i][j+1] && a[i][j]>=a[i-1][j] && a[i][j]>=a[i+1][j]) P;
					else if(j==n-1 && a[i][j]>=a[i][j-1] && a[i][j]>=a[i-1][j] && a[i][j]>=a[i+1][j]) P;
					else 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]) P;
				}
			}
		}
}
int main()
{
	int i,j,m,n,k=0,a[22][22],b[400],c[400];
	cin>>m>>n;
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			cin>>a[i][j];
	for(i=0;i<=m+1;i++)
	{
		a[i][0]=0;
		a[i][n+1]=0;
	}
	for(i=0;i<=n+1;i++)
	{
		a[0][i]=0;
		a[m+1][i]=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])
			{
				b[k]=i-1;
				c[k]=j-1;
				k++;
			}
	for(i=0;i<k;i++)
		cout<<b[i]<<" "<<c[i]<<endl;
	return 0;
}
int main()
{
	int m,n;
	cin>>m>>n;
	int a[m+2][n+2];
	for(int i=0;i<m+2;i++)
		for(int j=0;j<n+2;j++)
		{
			if(i==0||i==m+1||j==0||j==n+1)
				a[i][j]=0;
			else cin>>a[i][j];
		}
	for(int i=1;i<=m;i++)
		for(int 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;

}
/*
 * xzsd.cpp
 *
 *  Created on: 2012-12-16
 *      Author: patriciaxiao
 */

int main()
{
	int height[25][25]={{0}};
	int top[25][25]={{0}};  //?????
	int i,j;
	int m,n;
	scanf("%d %d",&m,&n);
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&height[i][j]);
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(top[i][j]==-1)  //??????????
				continue;
			if(height[i][j]>=height[i-1][j])
			{
				if(height[i][j]>height[i-1][j])
					top[i-1][j]=-1;
			}
			else
				continue;
			if(height[i][j]>=height[i+1][j])
			{
				if(height[i][j]>height[i+1][j])
					top[i+1][j]=-1;
			}
			else
				continue;
			if(height[i][j]>=height[i][j-1])
			{
				if(height[i][j]>height[i][j-1])
					top[i][j-1]=-1;
			}
			else
				continue;
			if(height[i][j]>=height[i][j+1])
			{
				if(height[i][j]>height[i][j+1])
					top[i][j+1]=-1;
			}
			else
				continue;
			printf("%d %d\n",i-1,j-1);
		}
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int raul[100][100],m,n,i,j;
	scanf("%d%d",&m,&n);
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&raul[i][j]);
		}

	}
	for(i=1;i<=m;i++)
	{
		raul[i][0]=0;
	}
	for(j=1;j<=n;j++)
	{
		raul[0][j]=0;
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(raul[i][j]>=raul[i+1][j]&&raul[i][j]>=raul[i-1][j]&&raul[i][j]>=raul[i][j-1]&&raul[i][j]>=raul[i][j+1])
					printf("%d %d\n",i-1,j-1);
		}
	}
	return 0;
}
int main()
{
	int m, n, i, a[21][21] = {0}, m1, n1;
	cin >> m >> n;
	for (i = 0; i <= m * n - 1; i++)
		cin >> a[i/n+1][i%n+1];
	for (i = 0; i <= m * n - 1; i++)
	{
		m1 = i / n + 1;
		n1 = i % n + 1;
		if (a[m1][n1] >= a[m1+1][n1] && a[m1][n1] >= a[m1-1][n1] && a[m1][n1] >= a[m1][n1+1] && a[m1][n1] >= a[m1][n1-1])
			cout << m1 - 1 << " " << n1 - 1 << endl;
	}
	return 0;
}
int main(){
	int m,n,i,j;
	cin>>m>>n;
	int h[m+2][n+2];
	memset(h,0,sizeof(h));
	for(i=1;i<m+1;i++)
		for(j=1;j<n+1;j++)
			cin>>h[i][j];
	for(i=1;i<m+1;i++)
		for(j=1;j<1+n;j++)
		{
			if((h[i][j]>=h[i][j+1])&&(h[i][j]>=h[i][j-1])&&(h[i][j]>=h[i+1][j])&&(h[i][j]>=h[i-1][j]))
				cout<<i-1<<" "<<j-1<<endl;
		}
	return 0;
}
int main()
{
	int i, j, m, n, a[20][20], k = 0;
	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(j + 1 < n)
				{
					if (a[i][j] >= a[i][j + 1]) 
						k++;
				}
				else
					k++;
				if(j - 1 >= 0)
				{
					if (a[i][j] >= a[i][j - 1]) 
						k++;
				}
				else
					k++;
				if (i + 1 < m)
				{
					if (a[i][j] >= a[i + 1][j])
						k++;
				}
				else
					k++;
				if (i - 1 >= 0)
				{
					if (a[i][j] >= a[i - 1][j])
						k++;
				}
				else
					k++;
				if (k == 4)
					cout << i << ' ' << j << endl;
				k = 0;
		}
	return 0;
}
int main()
{	
	int a,b,c,d,e,m,n,i,j,k,sz[22][22];
	for(i=0;i<m+2;i++){
	     for(j=0;j<n+2;j++){
	        sz[i][j]=0; 	
	     }
	}
	scanf("%d%d",&m,&n);
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j-1]){
				d=i-1;
				e=j-1;
				printf("%d %d\n",d,e);
			}
		}
	}
    return 0;
}
int main()
{
	int m,n,i,j;
	int sz[22][22]={0};
	scanf("%d %d",&m,&n);
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			scanf("%d ",&sz[i][j]);
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if((sz[i-1][j]<=sz[i][j])&&(sz[i+1][j]<=sz[i][j])&&(sz[i][j-1]<=sz[i][j]&&sz[i][j+1]<=sz[i][j])){
				printf("%d %d\n",i-1,j-1);
			}
		}
	}
	return 0;
}
int main()
{
	int sh[21][21];
	int m,n,i,j,t=0,f1=0,f2=0,f3=0,f4=0;
	cin >>m>>n;
	{
		for(i=0;i<m;i++)
			for(j=0;j<n;j++)
				cin >>sh[i][j];
		for(i=0;i<m;i++)
			for(j=0;j<n;j++)
			{
				t=sh[i][j];
				if((i-1<0)||(sh[i-1][j]<=t))
				{
					f1=1;
				}
				else continue;
				if((i+1>=m)||(sh[i+1][j]<=t))
				{
					f2=1;
				}
				else continue;
				if((j-1<0)||(sh[i][j-1]<=t))
				{
					f3=1;
				}
			else continue;
				if((j+1>=n)||(sh[i][j+1]<=t))
				{
					f4=1;
				}
				else continue;
				if(f1+f2+f3+f4==4)
					cout <<i<<" "<<j<<endl;
				f1=0;f2=0;f3=0;f4=0;
			}
	}	return 0;
}
int main()
{
int m,n,i,j;double a[200][200];
scanf("%d%d",&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%lf",&a[i][j]);
for(j=0;j<n;j++)
{if(j==0)
{if(a[0][j]>=a[0][j+1]&&a[0][j]>=a[1][j])
printf("%d %d\n",0,j);}
else if(j==n-1)
{if(a[0][j]>=a[0][j-1]&&a[0][j]>=a[1][j])
printf("%d %d\n",0,j);}
else if(a[0][j]>=a[0][j-1]&&a[0][j]>=a[1][j]&&a[0][j]>=a[0][j+1])                
printf("%d %d\n",0,j);
                }
                for(i=1;i<m-1;i++)
                for(j=0;j<n;j++)
                {if(j==0)
{if(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",i,j);}
else if(j==n-1)
{if(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",i,j);}
else 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",i,j);
                }
                for(j=0;j<n;j++)
{if(j==0)
{if(a[m-1][j]>=a[m-1][j+1]&&a[i][j]>=a[m-2][j])
printf("%d %d\n",m-1,j);}
else if(j==n-1)
{if(a[m-1][j]>=a[m-1][j-1]&&a[i][j]>=a[m-2][j])
printf("%d %d\n",m-1,j);}
else if(a[m-1][j]>=a[m-1][j-1]&&a[i][j]>=a[m-1][j+1]&&a[i][j]>=a[m-2][j])                
printf("%d %d\n",m-1,j);
                }
}
/*
 * 4.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int a[1000][1000];
	int m, n, i ,j;
	cin>>m>>n;
	for(i=1; i<=m; i++)
		for(j=1; j<=n; j++)
		{
			cin>>a[i][j];
		}
	for(i=0; i<=m+1; i++)
		a[i][0]=a[i][n+1]=-1;
	for(i=0; i<=n+1; i++)
		a[0][i]=a[m+1][i]=-1;
	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,a[20][20],i,j;
	int b,c,d,e;
	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++){
			if(i==0&&i!=m-1)
				b=0;
			else
				b=a[i-1][j]-a[i][j];
			if(j==0&&j!=n-1)
				c=0;
			else
				c=a[i][j-1]-a[i][j];
			if(i==m-1)
				d=0;
			else
				d=a[i+1][j]-a[i][j];
			if(j==n-1)
				e=0;
			else
				e=a[i][j+1]-a[i][j];
			if(b<=0&&c<=0&&d<=0&&e<=0)
				printf("%d %d\n",i,j);
		}
	}
	return 0;
}
int main()
{
	int m,n,i,j,h[30][30];
	float a;
	scanf("%d%d",&m,&n);
	for(i=0;i<n+2;i++)
		h[0][i]=h[m+1][i]=0;
	for(i=0;i<m+2;i++)
		h[i][0]=h[i][n+1]=0;
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			scanf("%d",&h[i][j]);
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
		{
			if(h[i][j]>=h[i][j-1]&&h[i][j]>=h[i][j+1]&&h[i][j]>=h[i-1][j]&&h[i][j]>=h[i+1][j])
			printf("%d %d\n",i-1,j-1);
		}
}
/*
 * 04.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int m,n;
	cin>>m>>n;
	const int m1=m,n1=n;
	int a[m1][n1];
	int i,j;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0])
	{
		cout<<"0 0"<<endl;
	}
	for(i=1;i<n-1;i++)
	{
		if(a[0][i]>=a[0][i-1]&&a[0][i]>=a[0][i+1]&&a[0][i]>=a[1][i])
		{
			cout<<"0 "<<i<<endl;
		}
	}
	if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1])
	{
		cout<<"0 "<<n-1<<endl;
	}
	for(i=1;i<m-1;i++)
	{
		if(a[i][0]>=a[i][1]&&a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0])
		{
			cout<<i<<" 0"<<endl;
		}
		for(j=1;j<n-1;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<<" "<<j<<endl;
			}
		}
		if(a[i][n-1]>=a[i][n-2]&&a[i][n-1]>=a[i-1][n-1]&&a[i][n-1]>=a[i+1][n-1])
		{
			cout<<i<<" "<<n-1<<endl;
		}
	}
	if(a[m-1][0]>=a[m-1][1]&&a[m-1][0]>=a[m-2][0])
	{
		cout<<m-1<<" 0"<<endl;
	}
	for(i=1;i<n-1;i++)
	{
		if(a[m-1][i]>=a[m-1][i-1]&&a[m-1][i]>=a[m-1][i+1]&&a[m-1][i]>=a[m-2][i])
		{
			cout<<m-1<<" "<<i<<endl;
		}
	}
	if(a[m-1][n-1]>=a[m-1][n-2]&&a[m-1][n-1]>=a[m-2][n-1])
	{
		cout<<m-1<<" "<<n-1<<endl;
	}
	return 0;
}
int main () {
	int m,n,i,j,a,b,c,d;
	int sz[22][22]={0};
	scanf("%d%d",&m,&n);
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			a=sz[i][j]-sz[i-1][j];
			b=sz[i][j]-sz[i+1][j];
			c=sz[i][j]-sz[i][j-1];
			d=sz[i][j]-sz[i][j+1];
			if(a>=0 && b>=0 && c>=0 && d>=0){
				printf("%d %d\n",i-1,j-1);
			}
		}
	}
	return 0;
}
int main()
{
	int a[30][30] = {0}, i , j, m, n,flag;
	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++)
		{
			flag = 1;
			if (j > 0)
				if (a[i][j-1] > a[i][j])
				{
					flag =0;
					continue;
				}
			if (j <n-1)
				if (a[i][j]<a[i][j+1])
				{
					flag =0;
					continue;
			
				}
			if (i > 0)
				if (a[i-1][j] > a[i][j])
				{
					flag =0;
					continue;
				
				}
			if (i< m-1)
			{
				if (a[i][j] < a[i+1][j])
				{
					flag =0;
					continue;

				}
			}
			if (flag ==1)
				cout << i << " "<<j<< endl;
		}

	return 0;
}
int main()
{
    int m,n,i,j,k;
    scanf("%d%d",&m,&n);
    int a[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++)
        {
            if(i==0&&j==0&&a[0][0]>=a[1][0]&&a[0][0]>=a[0][1])
            printf("0 0\n");
            else if(i==0&&j==(n-1)&&a[0][n-1]>=a[1][n-1]&&a[0][n-1]>=a[0][n-1])
            printf("0 %d\n",n-1);
            else if(i==(m-1)&&j==(n-1)&&a[m-1][n-1]>=a[m-2][n-1]&&a[m-1][n-1]>=a[m-1][n-2])
            printf("%d %d\n",m-1,n-1);
            else if(i==(m-1)&&j==0&&a[m-1][0]>a[m-2][0]&&a[m-1][0]>=a[m-1][1])  
            printf("%d 0\n",m-1);
            else if(i==0&&(j!=0||j!=(n-1))&&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(i==(m-1)&&(j!=0||j!=(n-1))&&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(j==0&&(i!=0||i!=(m-1))&&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(j==(n-1)&&(i!=0||i!=(m-1))&&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&&i<(m-1))&&(j>0&&j<(n-1))&&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",i,j);
        }
    }
    getchar();
    getchar();
}
int main(){
   int n,m,i,j,k,total=0,a[110][110];
   
   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++){
        if(i==0){
          if(j==0){
           if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]){
            printf("%d %d\n",i,j);
           }
          }
        if(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]){
            printf("%d %d\n",i,j);
             }
           }

        if(j==n-1){
           if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]){
            printf("%d %d\n",i,j);
          }
        }}//i==0

       if(i==m-1){
          if(j==0){
           if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]){
            printf("%d %d\n",i,j);
           }
          }
        if(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]){
            printf("%d %d\n",i,j);
             }
           }

        if(j==n-1){
           if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]){
            printf("%d %d\n",i,j);
          }
        }
        }
        //i=m-1
        if(i>0&&i<m-1){
          if(j==0){
           if(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",i,j);
           }
          }
        if(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]){
            printf("%d %d\n",i,j);
             }
           }

        if(j==n-1){
           if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]){
            printf("%d %d\n",i,j);
          }
        }
       }//{}
}}


return 0;
}
/*
 * ????.cpp
 *
 *  Created on: 2013-1-19
 *      Author: sony
 */
int main()
{
	int a[30][30];
	int m,n,i,j;
	cin>>m>>n;
	for(j=0;j<n+1;j++)
	{
		a[0][j]=0;
		a[m+1][j]=0;

	}
	for(i=0;i<m+1;i++)
	{
		a[i][0]=0;
		a[i][n+1]=0;
	}
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	for(i=0;i<m+1;i++)
		for(j=0;j<n+1;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]) && (i!=0) && (i!=m+1) &&(j!=0) && (j!=n+1))
				cout<<i-1<<' '<<j-1<<endl;
		}
	return 0;
}
int main()
{
	int m , n , i , j ;
	int mount[100][100] = { 0 } ;
	cin >> m >> n ;
	for ( i = 1 ; i <= m ; i++ )
	{
		for ( j = 1 ; j <= n ; j++ )
		{
			cin >> mount[i][j] ;
		}
	}
	int k ;
	for ( k = 0 ; k <= n+1 ; k++ )
	{
		mount[0][k] = 0 ;
		mount[m+1][k] = 0 ;
	}
	for ( k = 0 ; k <= m+1 ; k ++ )
	{
		mount[k][0] = 0 ;
		mount[k][n+1] = 0 ;
	}
	for ( i = 1 ; i <= m ; i++ )
	{
		for ( j = 1 ; j <= n ; j++ )
		{
			if ( mount[i][j] >= mount[i+1][j] && mount[i][j] >= mount[i-1][j] 
				&& mount[i][j] >= mount[i][j+1] && mount[i][j] >= mount[i][j-1] )
				{
					cout << i - 1 << " " << j - 1 << endl ;
				}
		}
	}
	return 0 ;
}
int main(){
	int m,n,k,g,i,c;
	int a[20][20];
	scanf("%d%d",&m,&n);
	for(k=0;k<=m-1;k++){
		for(g=0;g<=n-1;g++){
			scanf("%d",&a[k][g]);
		}
	}
	for(i=0;i<=m-1;i++){
		for(c=0;c<=n-1;c++){
			if(i==0&&c==0){
				if(a[i][c]>=a[i+1][c]&&a[i][c]>=a[i][c+1]){
					printf("%d %d\n",i,c);
				}
			}
			if(i==0&&c!=0&&c!=n-1){
				if(a[i][c]>=a[i+1][c]&&a[i][c]>=a[i][c-1]&&a[i][c]>=a[i][c+1]){
					printf("%d %d\n",i,c);
				}
			}
			if(i==0&&c==n-1){
				if(a[i][c]>=a[i+1][c]&&a[i][c]>=a[i][c-1]){
					printf("%d %d\n",i,c);
				}
			}
			if(i!=0&&i!=m-1&&c==0){
				if(a[i][c]>=a[i+1][c]&&a[i][c]>=a[i][c+1]&&a[i][c]>=a[i-1][c]){
					printf("%d %d\n",i,c);
				}
			}
			if(i==m-1&&c==0){
				if(a[i][c]>=a[i-1][c]&&a[i][c]>=a[i][c+1]){
					printf("%d %d\n",i,c);
				}
			}
			if(i==m-1&&c!=0&&c!=n-1){
				if(a[i][c]>=a[i-1][c]&&a[i][c]>=a[i][c+1]&&a[i][c]>=a[i][c-1]){
					printf("%d %d\n",i,c);
				}
			}
			if(c==n-1&&i!=0&&i!=m-1){
				if(a[i][c]>=a[i-1][c]&&a[i][c]>=a[i+1][c]&&a[i][c]>=a[i][c-1]){
					printf("%d %d\n",i,c);
				}
			}
			if(c==n-1&&i==m-1){
				if(a[i][c]>=a[i-1][c]&&a[i][c]>=a[i][c-1]){
					printf("%d %d\n",i,c);
				}
			}
			if(c!=0&&c!=n-1&&i!=0&&i!=m-1){
				if(a[i][c]>=a[i-1][c]&&a[i][c]>=a[i+1][c]&&a[i][c]>=a[i][c-1]&&a[i][c]>=a[i][c+1]){
					printf("%d %d\n",i,c);
				}
			}
		}
	}
	return 0;
}
void main()
{
	int a[20][20],b[20][20]={0},m,n,i,j;
	scanf("%d %d",&m,&n);
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
		scanf("%d",*(a+i)+j);
	//printf("%d",a[9][3]);
	if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0]) b[0][0]=1;
	if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1]) b[0][n-1]=1;
	if(a[m-1][0]>=a[m-1][1]&&a[m-1][0]>=a[m-2][0]) b[m-1][0]=1;
	if(a[m-1][n-1]>=a[m-2][n-1]&&a[m-1][n-1]>=a[m-1][n-2]) b[m-1][n-1]=1;
	for(j=1;j<n-1;j++)
	{
		if(a[0][j]>=a[0][j+1]&&a[0][j]>=a[0][j-1]&&a[0][j]>=a[1][j]) b[0][j]=1;
	}
	for(j=1;j<n-1;j++)
	{
		if(a[m-1][j]>=a[m-1][j+1]&&a[m-1][j]>=a[m-1][j-1]&&a[m-1][j]>=a[m-2][j]) b[m-1][j]=1;
	}
	for(i=1;i<m-1;i++)
	{
		if(a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0]&&a[i][0]>=a[i][1]) b[i][0]=1;
	}
	for(i=1;i<m-1;i++)
	{
		if(a[i][n-1]>=a[i-1][n-1]&&a[i][n-1]>=a[i+1][n-1]&&a[i][n-1]>=a[i][n-2]) b[i][n-1]=1;
	}
	for(i=1;i<m-1;i++)
		for(j=1;j<n-1;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])
				b[i][j]=1;
		
		}
//printf(",,%d,,",b[9][3]);
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
		{
			if(b[i][j]==1) printf("%d %d\n",i,j);
		}

}
int main()
{
	int m = 0, n = 0, i = 0, j = 0;
	cin >> m >> n;
	int a[500][500];
	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 && j == 0)
			{
				if(a[i][j] >= a[i+1][j] && a[i][j] >= a[i][j+1])
				{
					cout << i << " " << j <<endl;
				}
			}
			else if(i == 0 && j != 0 && j != n - 1)
			{
				if(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;
				}
			}
			else if(i == 0 && j == n - 1)
			{
				if(a[i][j] >= a[i+1][j] && a[i][j] >= a[i][j+1])
				{
					cout << i << " " << j <<endl;
				}
			}
			else if(i != 0 && i != m - 1 && j == 0)
			{
				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 != 0 && i != m - 1 && j == n - 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 && j == 0)
			{
				if(a[i][j] >= a[i-1][j] && a[i][j] >= a[i][j+1])
				{
					cout << i << " " << j <<endl;
				}
			}
			else if(i == m - 1 && j != 0 && j != n - 1)
			{
				if(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;
				}
			}
			else if(i == m - 1 && j == n - 1)
			{
				if(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-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;
}