semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int a[25][25] = {{0},{0}}, m, n;
	double average, sum = 0;
	cin >> m >> n;
	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;
	return 0;
}
int main()
{
	int m,n,i,j,h[20][20]={0},k[20][20]={0};
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			scanf("%d",&h[i][j]);
	for(i=0;i<m-1;i++)
		for(j=0;j<n;j++)
			k[i][j]+=cmp(h[i][j],h[i+1][j]);
	for(i=1;i<m;i++)
		for(j=0;j<n;j++)
			k[i][j]+=cmp(h[i][j],h[i-1][j]);
	for(i=0;i<m;i++)
		for(j=0;j<n-1;j++)
			k[i][j]+=cmp(h[i][j],h[i][j+1]);
	for(i=0;i<m;i++)
		for(j=1;j<n;j++)
			k[i][j]+=cmp(h[i][j],h[i][j-1]);
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			if(k[i][j]==0)
				printf("%d %d\n",i,j);
	return 0;
}
int cmp(int a,int b)
{
	return(a>=b? 0:1);
}
int main()
{
	int i,j,n,m;
	int high[21][21]={0};
	cin >> m >> n;
	for (i=0;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			cin >> high[i][j];
		}
	}
	for (i=0;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			if (i==0&&j==0)
			{
				if (high[i+1][j]<=high[i][j]&&high[i][j+1]<=high[i][j])
				{
					cout << i << " " << j << endl;
				}
			}
			if (i==0&&j!=0)
			{
				if (high[i+1][j]<=high[i][j]&&high[i][j+1]<=high[i][j]&&high[i][j-1]<=high[i][j])
				{
					cout << i << " " << j << endl;
				}
			}
			if (i!=0&&j==0)
			{
				if (high[i+1][j]<=high[i][j]&&high[i][j+1]<=high[i][j]&&high[i-1][j]<=high[i][j])
				{
					cout << i << " " << j << endl;
				}
			}
			if (i!=0&&j!=0)
			{
				if (high[i+1][j]<=high[i][j]&&high[i][j+1]<=high[i][j]&&high[i-1][j]<=high[i][j]&&high[i][j-1]<=high[i][j])
				{
					cout << i << " " << j << endl;
				}
			}
		}
	}
	return 0;
}
int main()
{
	int i,j,m,n,a[21][21];
	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==0)
			{
			    if(j==0)
				    if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
					    cout<<i<<" "<<j<<endl;
			    if(j>0&&j<n-1)
				    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;
			    if(j==n-1)
				    if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
					    cout<<i<<" "<<j<<endl;
			}
			if(i>0&&i<m-1)
			{
				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])
						cout<<i<<" "<<j<<endl;
				if(j>0&&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])
						cout<<i<<" "<<j<<endl;
				if(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;
			}
			if(i==m-1)
			{
				if(j==0)
					if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])
						cout<<i<<" "<<j<<endl;
				if(j>0&&j<n-1)
					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;
				if(j==n-1)
					if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
						cout<<i<<" "<<j<<endl;
			}
		}
	return 0;

}
//????


int main()
{
	int a[25][25] = {0}, 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 = 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,mount[30][30],i,j;
 cin>>m>>n;
 for(i=0;i<m;i++) for(j=0;j<n;j++) cin>>mount[i][j];   //?????? 
 for(i=0;i<m;i++) for(j=0;j<n;j++)
     {if(i==0&&j==0&&mount[0][0]>=mount[0][1]&&mount[0][0]>=mount[1][0]) cout<<i<<" "<<j<<endl; //?????0?????? 
        else if(i==0&&j==n-1&&mount[0][n-1]>=mount[0][n-2]&&mount[0][n-1]>=mount[1][n-1]) cout<<i<<" "<<j<<endl;
          else if(i==0&&mount[0][j]>=mount[0][j-1]&&mount[0][j]>=mount[0][j+1]&&mount[0][j]>=mount[1][j]) cout<<i<<" "<<j<<endl;
           else if(i==m-1&&j==n-1&&mount[m-1][n-1]>=mount[m-1][n-2]&&mount[m-1][n-1]>=mount[m-2][n-1]) cout<<i<<" "<<j<<endl;  //???????????? 
             else if(i==m-1&&j==0&&mount[m-1][0]>=mount[m-1][1]&&mount[m-1][0]>=mount[m-2][0]) cout<<i<<" "<<j<<endl;
               else if(i==m-1&&mount[m-1][j]>=mount[m-1][j-1]&&mount[m-1][j]>=mount[m-1][j+1]&&mount[m-1][j]>=mount[m-2][j]) cout<<i<<" "<<j<<endl;
                 else if(j==0&&mount[i][j]>=mount[i-1][j]&&mount[i][j]>=mount[i+1][j]&&mount[i][j]>=mount[i][1]) cout<<i<<" "<<j<<endl; //?????0?
                   else if(j==n-1&&mount[i][j]>=mount[i-1][j]&&mount[i][j]>=mount[i+1][j]&&mount[i][j]>=mount[i][n-2]) cout<<i<<" "<<j<<endl;  //??????1? 
                     else if(mount[i][j]>=mount[i][j-1]&&mount[i][j]>=mount[i-1][j]&&mount[i][j]>=mount[i][j+1]&&mount[i][j]>=mount[i+1][j]) cout<<i<<" "<<j<<endl; //???? 
                  }
 
 return 0;
    }
int main()
{
    int m,n;
    scanf("%d %d",&m,&n);
    int sz[m+2][n+2];
    for(int i=1;i<m+1;i++)
    {
        for(int j=1;j<n+1;j++)
        {
            scanf("%d",&sz[i][j]);
        }
    }
    for(int i=0;i<m+2;i++)
    {
        sz[i][0]=0;
        sz[i][n+1]=0;
    }
    for(int i=0;i<n+2;i++)
    {
        sz[0][i]=0;
        sz[m+1][i]=0;
    }
    for(int i=1;i<m+1;i++)
    {
        for(int j=1;j<n+1;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])
            {
                printf("%d %d\n",i-1,j-1);
            }
        }
    }
    return 0;
}
int main()
{
 int m,n,i,j;
 int WL[21][21];
 scanf("%d %d",&m,&n);
 for(i=0;i<m;i++)
 {
  for(j=0;j<n;j++)
  {
   scanf(" %d",&WL[i][j]);
  }
 }
 int a,b;
 b=m-1; 
    a=n-1;
 if(WL[0][0]>=WL[0][1]&&WL[0][0]>=WL[1][0])
 {
  printf("0 0\n");
 }
 for(i=1;i<n-1;i++)
 {
     if(WL[0][i]>=WL[0][i+1]&&WL[0][i]>=WL[1][i]&&WL[0][i]>=WL[0][i-1])
  {
   printf("0 %d\n",i);
  }
 }
 if(WL[0][n-1]>=WL[0][n-2]&&WL[0][n-1]>=WL[1][n-1])
 {
  
  printf("0 %d\n",a);
 }
    for(j=1;j<m-1;j++)
 {
		if(WL[j][0]>=WL[j-1][0]&&WL[j][0]>=WL[j+1][0]&&WL[j][0]>=WL[j][1])
			printf("%d %d\n",j,0);
  for(i=1;i<n-1;i++)
  {
          if(WL[j][i]>=WL[j-1][i]&&WL[j][i]>=WL[j][i-1]&&WL[j][i]>=WL[j+1][i]&&WL[j][i]>=WL[j][i+1])
   {
           printf("%d %d\n",j,i);
   }
  }
  if(WL[j][n-1]>=WL[j-1][n-1]&&WL[j][n-1]>=WL[j+1][n-1]&&WL[j][n-1]>=WL[j][n-2])
			printf("%d %d\n",j,a);
 }
   if(WL[m-1][0]>=WL[m-2][0]&&WL[m-1][0]>=WL[m-1][1])
 {
  printf("%d %d\n",b,0);
 }
 for(i=1;i<n-1;i++)
 {
     if(WL[m-1][i]>=WL[m-1][i+1]&&WL[m-1][i]>=WL[m-2][i]&&WL[m-1][i]>=WL[m-1][i-1])
  {
   printf("%d %d\n",b,i);
  }
 }
 
 
 if(WL[m-1][n-1]>=WL[m-2][n-1]&&WL[m-1][n-1]>=WL[m-1][n-2])
 {
  printf("%d %d\n",b,a);
 }

 return 0;
}
void main()
{ int m,n;
scanf("%d%d",&m,&n);
int str[100][100];
int i,j,p,q,a,b;
a=n+2;b=m+2;
for(j=0;j<n+2;j++){str[0][j]=0;}
for(j=0;j<n+2;j++){str[a][j]=0;}
for(i=0;i<m+2;i++){str[i][0]=0;}
for(i=0;i<m+2;i++){str[i][b]=0;}
for(i=1;i<m+1;i++)
  for(j=1;j<n+1;j++)
  {  scanf("%d",&str[i][j]);
  }
 for(i=1;i<m+2;i++)
  for(j=1;j<n+2;j++)
  {if(str[i][j]>0)
  {if( (str[i][j]>=str[i][j-1])&&(str[i][j]>=str[i][j+1])&&(str[i][j]>=str[i-1][j])&&(str[i][j]>=str[i+1][j]))
  {p=i-1;q=j-1;
  printf("%d %d\n",p,q);}}}
}
int main()
{
	int s[22][22],m,n,i,j;
	scanf("%d%d",&m,&n);
	memset(s,0,sizeof(s));
    for(i=1;i<=m;i++){
		for(j=1;j<=n;j++)
			scanf("%d",&s[i][j]);
	}
    for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(s[i][j]>s[i-1][j]-1&&s[i][j]>s[i+1][j]-1&&s[i][j]>s[i][j+1]-1&&s[i][j]>s[i][j-1]-1)
				printf("%d %d\n",i-1,j-1);
		}
	}
	return 0;
}
int main()
{
    int height[22][22],top[21][21];
    int m=0,n=0,i=0,j=0;
    cin>>m>>n;
    for(i=0;i<=m+1;i++)
       for(j=0;j<=n+1;j++)
       {
           if(i==0 || j==0 || i==m+1 || j==n+1) height[i][j]=0;
           else cin>>height[i][j];
           top[i][j]=0;
       }
    for(i=1;i<=m;i++)
       for(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])
           top[i][j]=1;
       }
    for(i=0;i<=m;i++)
       for(j=0;j<=n;j++)
       if(top[i][j]==1)
        cout<<i-1<<" "<<j-1<<endl;
        return 0;
}
int main(){
	int m, n;
	int a[22][22];

	scanf("%d%d", &m, &n);
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
			scanf("%d", &a[i][j]);
	for (int i = 0; i <= m+1; i++)
		a[i][0] = a[i][n+1] = 0;
	for (int j = 1; j <= n; j++)
		a[0][j] = a[m+1][j] = 0;

	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++){
			if (a[i][j] >= a[i][j - 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-1, j-1);
		}
}
/*
 * 1.cpp
 *
 *  Created on: 2011-12-25
 *      Author: Administrator
 */
int main()
{
	int i,j,m,n;
	int a[50][50];
	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(a[i+1][j]>a[i][j]) continue;
			if(a[i][j+1]>a[i][j]) continue;
			if(i!=0 && a[i-1][j]>a[i][j])continue;
			if(j!=0 && a[i][j-1]>a[i][j])continue;
			cout<<i<<' '<<j<<endl;
		}
	return 0;
}
int main()
{	
	int m,n,w,q,j,i,e,sz[100][100],sz1[100],sz2[100],x=0,y=0;	
	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])
			{	
				printf("%d %d\n",q,w);	
			}	
		}	
	}	
	return 0;
}
int main(int argc, char* argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	int a[20][20];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int k=0;k<n;k++)
	{
		for(int l=0;l<m;l++)
		{
			if((k==0&&l==0) && a[k][l]>=a[k][l+1]&&a[k][l]>=a[k+1][l]){
				printf("%d %d\n",k,l);
			}
			else if((k==0&&l!=m-1&&l!=0)&&a[k][l]>=a[k][l-1]&&a[k][l]>=a[k+1][l]&&a[k][l]>=a[k][l+1]){
				printf("%d %d\n",k,l);
			}
			else if((k==0&&l==m-1)&&a[k][l]>=a[k][l-1]&&a[k][l]>=a[k+1][l]){
				printf("%d %d\n",k,l);
			}
			else if((k!=n-1&&k!=0&&l==0)&&a[k][l]>=a[k][l+1]&&a[k][l]>=a[k+1][l]&&a[k][l]>=a[k-1][l]){
				printf("%d %d\n",k,l);
			}
			else if((k!=n-1&&l!=m-1&&k!=0&&l!=0)&&a[k][l]>=a[k][l+1]&&a[k][l]>=a[k-1][l]&&a[k][l]>=a[k+1][l]&&a[k][l]>=a[k][l-1]){
				printf("%d %d\n",k,l);
			}
			else if((k!=n-1&&k!=0&&l==m-1)&&a[k][l]>=a[k][l-1]&&a[k][l]>=a[k+1][l]&&a[k][l]>=a[k-1][l]){
				printf("%d %d\n",k,l);
			}
			else if((k==n-1&&l==0)&&a[k][l]>=a[k][l+1]&&a[k][l]>=a[k-1][l]){
				printf("%d %d\n",k,l);
			}
			else if((k==n-1&&l!=m-1&&l!=0)&&a[k][l]>=a[k][l-1]&&a[k][l]>=a[k][l+1]&&a[k][l]>=a[k-1][l]){
				printf("%d %d\n",k,l);
			}
			else if((k==n-1&&l==m-1)&&a[k][l]>=a[k-1][l]&&a[k][l]>=a[k][l-1]){
				printf("%d %d\n",k,l);
			}
		}
	}
	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 p = 0; p < m; p++)
	{
		for (int q = 0; q < n; q++)
		{
			int s = 0;
			if (p - 1 < 0) s++;
			if (p - 1 >= 0 && a[p - 1][q] <= a[p][q]) s++;
			if (p + 1 >= m) s++;
			if (p + 1 < m && a[p + 1][q] <= a[p][q]) s++;
			if (q - 1 < 0) s++;
			if (q - 1 >= 0 && a[p][q - 1] <= a[p][q]) s++;
			if (q + 1 >= n) s++;
			if (q + 1 < n && a[p][q + 1] <= a[p][q]) s++;
			if (s == 4)
				cout << p << ' ' << q << endl;
		}
	}

	return 0;
}
int main(){
    int m,n; 
    scanf("%d %d",&m,&n);
    int sd[m+2][n+2];
    int i,j;
    for(i=0;i<m+2;i++){
       for(j=0;j<n+2;j++){
         sd[i][j]=0;
                          }
                       }
    for(i=1;i<m+1;i++){
       for(j=1;j<n+1;j++){
          scanf("%d",&sd[i][j]);
                        }
                     }
     for(i=1;i<m+1;i++){
       for(j=1;j<n+1;j++){
         if(sd[i][j]>=sd[i+1][j]&&sd[i][j]>=sd[i-1][j]&&sd[i][j]>=sd[i][j+1]&&sd[i][j]>=sd[i][j-1]){
            printf("%d %d\n",i-1,j-1);
                                                                                                    }
                       }
                     }
     return 0;
    
    
    }
int main()
{
	int a[25][25];
	int n,m,i,j;
	scanf("%d%d",&m,&n);
	for(i=1;i<=m;i++)
	{
		a[i][0]=a[i][n+1]=-1;
		for(j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			a[0][j]=a[m+1][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",i-1,j-1);
		}
	}
	return 0;
}
int main() {
	int m, n, i, j;
	cin >> m >> n;
	int a[m][n];
	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 (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]) {
			cout << 0 << " " << j << 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][j + 1] && a[i][j] >= a[i][j - 1] && a[i][j]
					>= a[i - 1][j] && a[i][j] >= a[i + 1][j]) {
				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 (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]) {
			cout << m - 1 << " " << j << 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;
}
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++)
          {
              if(j==0)
               scanf("%d",&a[i][j]);
               else
               scanf("%d",&a[i][j]);
          }
      }
      for(i=0;i<m;i++)
      {
           for(j=0;j<n;j++)
           {
                 if(j!=0)
                 {
                         if(a[i][j-1]>a[i][j])
                 continue;
                 }
                 if(j!=n-1)
                 {
                           if(a[i][j+1]>a[i][j])
                 continue;
                 }
                 if(i!=m-1)
                 {
                           if(a[i+1][j]>a[i][j])
                 continue;
                 }
                 if(i!=0)
                 {
                         if(a[i-1][j]>a[i][j])
                 continue;
                 }
                 printf("%d %d\n",i,j);
           }
      }
      getchar();
      getchar();
      getchar();
}
int main()
{
	int m,n,i,j;
	int a[25][25];
	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==0)&&(j==0))
				{
					if((a[0][0]>=a[0][1])&&(a[0][0]>=a[1][0]))
						cout<<i<<' '<<j<<endl;
				}
				else if((i==0)&&(j==n-1))
				{
					if((a[0][n-1]>=a[0][n-2])&&(a[0][n-1]>=a[1][n-1]))
						cout<<i<<' '<<j<<endl;
				}
				else if((i==m-1)&&(j==n-1))
								{
									if((a[m-1][n-1]>=a[m-1][n-2])&&(a[m-1][n-1]>=a[m-2][n-1]))
										cout<<i<<' '<<j<<endl;
								}
				else if((i==m-1)&&(j==0))
												{
													if((a[m-1][0]>=a[m-1][1])&&(a[m-1][0]>=a[m-2][0]))
														cout<<i<<' '<<j<<endl;
												}
				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]))
							cout<<i<<' '<<j<<endl;
					}
					else if(i==m-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(j==0)
															{
																if((a[i][j]>=a[i-1][j])&&(a[i][j]>=a[i][j+1])&&(a[i][j]>=a[i+1][j]))
																	cout<<i<<' '<<j<<endl;
															}
					else 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]))
																	cout<<i<<' '<<j<<endl;
															}
					else{if((a[i][j]>=a[i-1][j])&&(a[i][j]>=a[i][j-1])&&(a[i][j]>=a[i+1][j])&&(a[i][j]>=a[i][j+1]))
						cout<<i<<' '<<j<<endl;

					}

				}
			}

	return 0;
}
int read();
void tj();
void print();
int a[20][20],b[20][20],m,n;
int main()
{
	read();
	tj();
	print();
	return 0;
}
int read()
{
    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]);
			b[i][j]=0;
		}
		return 0;
}
void tj()
{
	int 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+1][j]&&a[i][j]>=a[i][j+1]) b[i][j]=1;
			    else if (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;
			 }
			 if (j==0) 
			 {if (i==0&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]) b[i][j]=1;
			    else if (a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]) b[i][j]=1;
			 }
			 if (i==m-1)
		    	{if (j==n-1&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]) b[i][j]=1;
				else if (a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]) b[i][j]=1;
			 }
			 if (j==n-1)
			 {if (i==m-1&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]) b[i][j]=1;
				else if (a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]) b[i][j]=1;
			 }
             if (i!=0&&j!=0&&i!=m-1&&j!=n-1&&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])
				 b[i][j]=1;
		}
		return;
}
void print()
{
	int i,j;
		for (i=0;i<m;i++)
			for (j=0;j<n;j++)
			{if (b[i][j]==1)
			 printf("%d %d\n",i,j);
			}
			return;
}
int main()
{
int a,c,i,j;
int k=0;
scanf("%d%d",&a,&c);
int b[100][100];
for(i=0;i<100;i++){
for(j=0;j<100;j++)
{b[i][j]=0;
}}
for(i=1;i<=a;i++){
for(j=1;j<=c;j++)
{scanf("%d",&b[i][j]);
}}
for(i=1;i<=a;i++){
for(j=1;j<=c;j++){
if(b[i][j]>=(b[i][j-1])&&
b[i][j]>=(b[i-1][j])&&
b[i][j]>=(b[i][j+1])&&
b[i][j]>=(b[i+1][j]))
printf("%d %d\n",i-1,j-1);
}}
return 0;
}
/*
 * 1234.cpp
 *
 *  Created on: 2011-1-9
 *      Author: c130
 */
int main()
{
	int m,n,i,j;
	int a[21][21];
	cin >> m  >> n;
	for(i=0;i<m;i++)
	{
		a[i][0]=0;
		a[i][n+1]=0;
	}
	for(i=0;i<m;i++)
		for(j=1;j<=n;j++)
			cin >> a[i][j];
	for(j=1;j<=n;j++)
		if(a[0][j]>=a[0][j-1]&&a[0][j]>=a[0][j+1]&&a[0][j]>=a[1][j])
			cout << 0 << " " << j-1 << endl;
	for(i=1;i<m-1;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])
					cout << i << " " << j-1 << endl;
	for(j=1;j<=n;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])
				cout << m-1 << " " << j-1 << endl;
	return 0;
}
int a[25][25] = {0};
void check(int i, int 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;
}

int main()
{
	int i, j, m, n;
	cin >> m >> n;
	for (i = 1; i <= m; i++)
		for (j = 1; j <= n; j++)
			cin >> a[i][j];
	for (i = 1; i <= m; i++)
		for (j = 1; j <= n; j++)
			check(i, j);
	return 0;
}
void main()
{
	int m,n,i,j;
	int c[20][20];
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			scanf("%d",&c[i][j]);
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i==0)
			{
				if(j==0)
				{
					if(c[i][j]>=c[i+1][j] && c[i][j]>=c[i][j+1])
						printf("%d %d\n",i,j);
				}
				else if(j==n-1)
				{
					if(c[i][j]>=c[i+1][j] && c[i][j]>=c[i][j-1])
						printf("%d %d\n",i,j);
				}
				else if(j>0 && j<n-1)
				{
					if(c[i][j]>=c[i][j-1] && c[i][j]>=c[i][j+1] && c[i][j]>=c[i+1][j])
						printf("%d %d\n",i,j);
				}
				
			}
			else if(i==m-1)
			{
				
				if(j>0 && j<n-1)
					if(c[i][j]>=c[i][j-1] && c[i][j]>=c[i][j+1] && c[i][j]>=c[i-1][j])
						printf("%d %d\n",i,j);
				if(j==0)
					if(c[i][j]>=c[i-1][j] && c[i][j]>=c[i][j+1])
						printf("%d %d\n",i,j);
				if(j==n-1)
					if(c[i][j]>=c[i-1][j] && c[i][j]>=c[i][j-1])
						printf("%d %d\n",i,j);
			}
			else if(i>0 && i<m-1)
			{
				if(j==0)
				{
					if(c[i][j]>=c[i][j+1] && c[i][j]>=c[i-1][j] && c[i][j]>=c[i+1][j])
						printf("%d %d\n",i,j);
				}
				else if(j>0 && j<n-1)
				{
					if(c[i][j]>=c[i][j-1] && c[i][j]>=c[i][j+1] && c[i][j]>=c[i-1][j] && c[i][j]>=c[i+1][j])
						printf("%d %d\n",i,j);
				}
				else if(j==n-1)
				{
					if(c[i][j]>=c[i-1][j] && c[i][j]>=c[i+1][j] && c[i][j]>=c[i][j-1])
						printf("%d %d\n",i,j);
				}
			}
		}
	}
}
int main(){
    int a[100][100];
    int m,n,i,b,c,d;
    scanf("%d %d",&m,&n);
    for(i=1;i<=m;i++){
        for(b=1;b<=n;b++){
            scanf("%d",&a[i][b]);
        }
    }
    for(i=1;i<=m;i++){
        for(b=1;b<=n;b++){
            if((a[i][b]>=a[i][b-1])&&
				(a[i][b]>=a[i][b+1])&&
				(a[i][b]>=a[i-1][b])&&
				(a[i][b]>=a[i+1][b])){
				c=i-1;
				d=b-1;
				printf("%d %d\n",c,d);
			}
        }
    }
    return 0;
}
int main()
{
	int m,n,i,j;
	int a[25][25]={0};
	scanf ("%d %d",&m,&n);
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=n+1;j++)
			if (j!=n+1)
				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] && a[i][j]!=0)
				printf ("%d %d\n",i-1,j-1);
		}
	}
	return 0;
}
//********************************
//*???4.cpp   **
//*?????? 1200012768 **
//*???2013.1.4  **
//*???????  **
//********************************
int main()
{
	int m, n, i, j, h[22][22] = {0}, flag[20][20] = {0};
	cin >> m >> n;
	for (i = 1; i <= m; i++)
		for (j = 1; j <= n; j++)
			cin >> h[i][j];
	for (i = 1; i <= m; i++)
		for (j = 1; j <= n; j++)
		{
			if (h[i][j] >= h[i - 1][j])
				flag[i][j]++;
			if (h[i][j] >= h[i + 1][j])
				flag[i][j]++;
			if (h[i][j] >= h[i][j - 1])
				flag[i][j]++;
			if (h[i][j] >= h[i][j + 1])
				flag[i][j]++;
			if (flag[i][j] == 4)
				cout << i - 1 << " " << j - 1 << endl;
		}
	return 0;
}
int main()  {
    int m,n,row,col,x,y,p,q;
    scanf("%d %d",&m,&n);
    int sz[m+2][n+2];
    for(row=0;row<m+2;row++){
        for(col=0;col<n+2;col++){
            if(row==0||row==m+1||col==0||col==n+1){
                sz[row][col]=0;
            }else{
              scanf("%d",&(sz[row][col]));
            }
        }
    }
    for(row=1;row<m+1;row++){
        for(col=1;col<n+1;col++){
            if(sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row-1][col]){
                printf("%d %d\n",row-1,col-1);
            }
        }
    }
    return 0;
}
int main()
{
	int m,n,h[21][21]={0},t[21][21]={0};
	cin >> m >> n;
	int i,j;
	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( (h[i][j] >= h[i-1][j]) && (h[i][j] >= h[i+1][j]) && (h[i][j] >= h[i][j-1]) && (h[i][j] >= h[i][j+1]) )
			{
				t[i][j]=1;
			}
		}
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if( t[i][j]==1)
			{
				cout << i << " " << j << endl;
			}
		}
	}
	return 0;
}
int main(){
   int i,j,m,n,count=0;
   int sz[22][22];
   scanf("%d %d",&m,&n);
   for(i=0;i<m+2;i++){
      for(j=0;j<n+2;j++){
        sz[i][j]=0;
      }
   }
   for(i=1;i<m+1;i++){
      for(j=1;j<n;j++){
        scanf("%d ",&sz[i][j]);
      }
      scanf("%d",&sz[i][n]);
   }
   for(i=1;i<m+1;i++){
      for(j=1;j<n+1;j++){
        if(sz[i+1][j]-sz[i][j]<=0&&sz[i-1][j]-sz[i][j]<=0&&sz[i][j+1]-sz[i][j]<=0&&sz[i][j-1]-sz[i][j]<=0){
                printf("%d %d\n",i-1,j-1);
        }
      }
   }
   return 0;
}
int main(){
	int i,a,b,m,n,dk[100][100];
	scanf("%d%d",&m,&n);
    for(a=1;a<=m;a++)
	{
		for(b=1;b<=n;b++)
		{
			scanf("%d",&dk[a][b]);
		}
	}
    for(i=0;i<=n+1;i++)
		dk[0][i]=0;
		dk[m+1][i]=0;
	for(i=0;i<=m+1;i++)
		dk[i][0]=0;
		dk[i][n+1]=0;
    for(a=1;a<m+1;a++)
	{
		for(b=1;b<n+1;b++)
		{
			if((dk[a][b]>=dk[a-1][b])&&(dk[a][b]>=dk[a+1][b])&&(dk[a][b]>=dk[a][b-1])&&(dk[a][b]>=dk[a][b+1]))
			{
			   printf("%d %d\n",a-1,b-1);
			}
		}
	}
return 0;
}