semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int topjudge(int a[][20],int m,int n,int p,int q)
{
	if(p==0)
		if(q==0)
			if(a[p][q]<a[p+1][q]||a[p][q]<a[p][q+1])
				return 0;
			else
				return 1;
		else if(q==n-1)
			if(a[p][q]<a[p+1][q]||a[p][q]<a[p][q-1])
				return 0;
			else
				return 1;
		else
			if(a[p][q]<a[p+1][q]||a[p][q]<a[p][q-1]||a[p][q]<a[p][q+1])
				return 0;
			else
				return 1;
	else if(p==m-1)
		if(q==0)
			if(a[p][q]<a[p-1][q]||a[p][q]<a[p][q+1])
				return 0;
			else
				return 1;
		else if(q==n-1)
			if(a[p][q]<a[p-1][q]||a[p][q]<a[p][q-1])
				return 0;
			else
				return 1;
		else
			if(a[p][q]<a[p-1][q]||a[p][q]<a[p][q-1]||a[p][q]<a[p][q+1])
				return 0;
			else
				return 1;
	else
	    if(q==0)
			if(a[p][q]<a[p-1][q]||a[p][q]<a[p+1][q]||a[p][q]<a[p][q+1])
				return 0;
			else
				return 1;
		else if(q==n-1)
			if(a[p][q]<a[p-1][q]||a[p][q]<a[p+1][q]||a[p][q]<a[p][q-1])
				return 0;
			else
				return 1;
		else
			if(a[p][q]<a[p-1][q]||a[p][q]<a[p+1][q]||a[p][q]<a[p][q-1]||a[p][q]<a[p][q+1])
				return 0;
			else
				return 1;
}

int main()
{
	int a[20][20],b[20][2];
	int m,n,i,j,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(topjudge(a,m,n,i,j)==1)
			{
				b[k][0]=i;
				b[k][1]=j;
				k++;
			}
			for(i=0;i<k;i++)
				printf("%d %d\n",b[i][0],b[i][1]);


	return 0;
}
int main()
{
int a[22][22];
int m,n;
int i,j;
scanf("%d%d",&m,&n);
for(i=0;i<m+2;i++){
    for(j=0;j<n+2;j++){
        a[0][j]=0;
        a[i][0]=0;
        a[m+1][j]=0;
        a[i][n+1]=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][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;
int sz[22][22];
scanf("%d%d",&m,&n);
for(int k=0;k<m;k++){
for(int l=0;l<n;l++){
scanf("%d",&(sz[k][l]));} 
}
for(int i=0; i<m;i++)
{
for(int j=0; j<n;j++)
{
if(i==0)
{
    if(((j==0)&&(sz[i][j]>=sz[i+1][j])&&(sz[i][j]>=sz[i][j+1]))||
    ((j==n-1)&&(sz[i][j]>=sz[i+1][j])&&(sz[i][j]>=sz[i][j-1]))||
    ((sz[i][j]>=sz[i][j-1])&&(sz[i][j]>=sz[i][j+1])&&(sz[i][j]>=sz[i+1][j])))
    {printf("%d %d\n",i,j);}
}
else
{
if(i==m-1)
{
    if(((j==0)&&(sz[i][j]>=sz[i-1][j])&&(sz[i][j]>=sz[i][j+1]))||
    ((j==n-1)&&(sz[i][j]>=sz[i-1][j])&&(sz[i][j]>=sz[i][j-1]))||
    ((sz[i][j]>=sz[i][j-1])&&(sz[i][j]>=sz[i][j+1])&&(sz[i][j]>=sz[i-1][j])))
    {printf("%d %d\n",i,j);}
}
else
{
    if(((j==0)&&(sz[i][j]>=sz[i+1][j])&&(sz[i][j]>=sz[i][j+1])&&(sz[i][j]>=sz[i-1][j]))||
    ((j==n-1)&&(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])&&(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,j);}
}
}
}
}
return 0;
}
int main(){
    int m,n;
    scanf("%d%d",&m,&n);
    int x,y;
    int i,k;
    int z[m+2][n+2];
    for(i=0;i<m+2;i++){
    for(k=0;k<n+2;k++){
        z[i][k]=0;
    }
    }
    for(i=1;i<m+1;i++){
        for(k=1;k<n+1;k++){
            scanf("%d",&(z[i][k]));
        }
    }
    for(i=1;i<m+1;i++){
    for(k=1;k<n+1;k++){
    if(z[i][k]>=z[i-1][k]&&z[i][k]>=z[i+1][k]&&z[i][k]>=z[i][k-1]&&z[i][k]>=z[i][k+1]){
    printf("%d %d\n",i-1,k-1);
}
}
}    
    return 0;
}
int main(){
    int n,m;
    int a[22][22]={0};

    scanf("%d %d",&m,&n);
    for(int i=1;i<m+1;i++){
        for(int t=1;t<n+1;t++){
            scanf("%d",&a[i][t]);}}
    for(int p=1;p<m+1;p++){
        for(int q=1;q<n+1;q++){ 
            if(a[p][q]>(a[p-1][q]-1)&&a[p][q]>(a[p+1][q]-1)&&a[p][q]>(a[p][q-1]-1)&&a[p][q]>(a[p][q+1]-1)){           
  printf("%d %d\n",p-1,q-1);}}}
                return 0;

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

	for(j=0;j<=n+1;j++)
		a[0][j]=0;
	for(j=1;j<=m;j++)
		a[j][0]=0;
	for(j=1;j<=m;j++)
		a[j][n+1]=0;
	for(j=0;j<=n+1;j++)
		a[m+1][j]=0;
	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])
				cout<<i-1<<' '<<j-1<<endl;
		}
	return 0;

}
int main()
{
	int m, n;
	cin >> m >> n;
	int i, j, h[21][21];
	for (i = 0; i <= n + 1; i++)
		h[0][i] = 0;
	for (i = 0; i <= n + 1; i++)
		h[m + 1][i] = 0;
	for (i = 0; i <= m + 1; i++)
		h[i][0] = 0;
	for (i = 0; i <= m + 1; i++)
		h[i][n + 1] = 0;
	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] && h[i][j] >= h[i - 1][j] && h[i][j] >= h[i][j + 1] && h[i][j] >= h[i][j - 1])
				cout << i - 1 << " " << j - 1 << endl;
		}
	return 0;
}
int main(){
    int m,n,i,j,a,b;
    a=0;
    scanf("%d %d",&m,&n);
    int sg[100][100],sz1[1000],sz2[1000];
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%d",&(sg[i][j]));
        }
    }
    if(sg[0][0]>=sg[0][1]&&sg[0][0]>=sg[1][0]){
        sz1[a]=0;sz2[a]=0;
        a++;
    }
    if(sg[0][n-1]>=sg[0][n-2]&&sg[0][n-1]>=sg[1][n-1]){
        sz1[a]=0;sz2[a]=n-1;
        a++;
    }
    if(sg[m-1][0]>=sg[m-1][1]&&sg[m-1][0]>=sg[m-2][0]){
        sz1[a]=m-1;sz2[a]=0;
        a++;
    }
    if(sg[m-1][n-1]>=sg[m-1][n-2]&&sg[m-1][n-1]>=sg[m-2][n-1]){
        sz1[a]=m-1;sz2[a]=n-1;
        a++;
    }
    if(n>1){
        for(j=1;j<n-1;j++){
            if(sg[0][j]>=sg[0][j+1]&&sg[0][j]>=sg[1][j]&&sg[0][j]>=sg[0][j-1]){
                sz1[a]=0;sz2[a]=j;
                a++;
            }
        }
    }
    if(m>1&&n>1){
        for(j=1;j<n-1;j++){
            if(sg[m-1][j]>=sg[m-1][j+1]&&sg[m-1][j]>=sg[m-2][j]&&sg[m-1][j]>=sg[m-1][j-1]){
                sz1[a]=m-1;sz2[a]=j;
                a++;
            }
        }
    }
     if(m>1){
        for(i=1;i<m-1;i++){
            if(sg[i][0]>=sg[i+1][0]&&sg[i][0]>=sg[i-1][0]&&sg[i][0]>=sg[i][1]){
                sz1[a]=i;sz2[a]=0;
                a++;
            }
        }
    }
    if(m>1&&n>1){
        for(i=1;i<m-1;i++){
            if(sg[i][n-1]>=sg[i+1][n-1]&&sg[i][n-1]>=sg[i-1][n-1]&&sg[i][n-1]>=sg[i][n-2]){
                sz1[a]=i;sz2[a]=j=n-1;
                a++;
            }
        }
    }
    if(m>1&&n>1)
        for(i=1;i<m-1;i++){
            for(j=1;j<n-1;j++){
                if(sg[i][j]>=sg[i-1][j]&&sg[i][j]>=sg[i+1][j]&&sg[i][j]>=sg[i][j-1]&&sg[i][j]>=sg[i][j+1]){
                    sz1[a]=i;sz2[a]=j;
                    a++;
                }
            }
        }
    
    for(int k=0;k<a-1;k++){
        int e;
        for(b=1;b<a-k;b++){
            if(sz1[b-1]>sz1[b]||(sz1[b-1]==sz1[b]&&sz2[b-1]>sz2[b])){
                e=sz1[b];
                sz1[b]=sz1[b-1];
                sz1[b-1]=e;
                
                e=sz2[b];
                sz2[b]=sz2[b-1];
                sz2[b-1]=e;
            }
        
        }
    
}
for(b=0;b<a;b++){
    printf("%d %d\n",sz1[b],sz2[b]);
}
return 0;
}
int main()
{
	int high[30][30];
	int m,n;
	cin>>m>>n;
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++) cin>>high[i][j];
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
		{
			if(i==0&&j==0) 
			{
				if(high[i][j]>=high[i+1][j]&&high[i][j]>=high[i][j+1]) cout<<i<<' '<<j<<endl;
			}
			else if(i==0&&j!=0) 
			{
				if(high[i][j]>=high[i][j+1]&&high[i][j]>=high[i][j-1]&&high[i][j]>=high[i+1][j]) cout<<i<<' '<<j<<endl;
			}
			else if(i!=0&&j==0) 
			{
				if(high[i][j]>=high[i+1][j]&&high[i][j]>=high[i-1][j]&&high[i][j]>=high[i][j+1]) cout<<i<<' '<<j<<endl;
			}
			else if(i==m-1&&j==n-1) 
			{
				if(high[i][j]>high[i-1][j]&&high[i][j]>=high[i][j-1]) cout<<i<<' '<<j<<endl;
			}
			else if(i==m-1&&j!=n-1) 
			{
				if(high[i][j]>=high[i-1][j]&&high[i][j]>=high[i][j+1]&&high[i][j]>=high[i][j-1]) cout<<i<<' '<<j<<endl;
			}
			else if(i!=m-1&&j==n-1) 
			{
				if(high[i][j]>=high[i-1][j]&&high[i][j]>=high[i][j-1]&&high[i][j]>=high[i+1][j]) cout<<i<<' '<<j<<endl;
			}
			else 
			{
				if(high[i][j]>=high[i+1][j]&&high[i][j]>=high[i-1][j]&&high[i][j]>=high[i][j+1]&&high[i][j]>=high[i][j-1]) cout<<i<<' '<<j<<endl;
			}
		}

	return 0;
}
int m,n;
int a[25][25];
int judge (int y, int x)
{
	if (y==0)
	{
		if (x==0)
		{
			if (a[x][y]>=a[x+1][y] && a[x][y]>=a[x][y+1])
				return 1;
		}
		else if (x==m-1)
		{
			if (a[x][y]>=a[x-1][y] && a[x][y]>=a[x][y+1])
				return 1;
		}
		else
		{
			if (a[x][y]>=a[x-1][y] && a[x][y]>=a[x+1][y] && a[x][y]>=a[x][y+1])
				return 1;
		}
	}
	else if (y==n-1)
	{
		if (x==0)
		{
			if (a[x][y]>=a[x+1][y] && a[x][y-1])
				return 1;
		}
		else if (x==m-1)
		{
			if (a[x][y]>=a[x-1][y] && a[x][y]>=a[x][y-1])
				return 1;
		}
		else
		{
			if (a[x][y]>=a[x-1][y] && a[x][y]>=a[x+1][y] && a[x][y]>=a[x][y-1])
				return 1;
		}
	}
	else
	{
		if (x==0)
		{
			if (a[x][y]>=a[x+1][y] && a[x][y]>=a[x][y+1] && a[x][y]>=a[x][y-1])
				return 1;
		}
		else if (x==m-1)
		{
			if (a[x][y]>=a[x-1][y] && a[x][y]>=a[x][y+1] && a[x][y]>=a[x][y-1])
				return 1;
		}
		else
		{
			if (a[x][y]>=a[x+1][y] && a[x][y]>=a[x-1][y] && a[x][y]>=a[x][y+1] && a[x][y]>=a[x][y-1])
				return 1;
		}
	}
	return 0;
}
main()
{

	scanf("%d %d",&m,&n);
	int i,j;
	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 (judge(j,i))
                printf("%d %d\n",i,j);
		}
}
void main()
{
	int m,n,i,j,k;
	int s[20][20];
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
			scanf("%d",&s[i][j]);
	}
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			if(i==0&&j==0)
			{
				if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j+1])
					printf("%d %d\n",i,j);
			}
			else if(i==0&&j<n-1)
			{
				if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j+1]&&s[i][j]>=s[i][j-1])
					printf("%d %d\n",i,j);
			}
			else if(i==0&&j==n-1)
			{
				if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j-1])
					printf("%d %d\n",i,j);
			}
			else if(i<m-1&&j==0)
			{
				if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j+1]&&s[i][j]>=s[i-1][j])
					printf("%d %d\n",i,j);
			}
			else if(i<m-1&&j<n-1)
			{
				if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j-1]&&s[i][j]>=s[i-1][j]&&s[i][j]>=s[i][j+1])
					printf("%d %d\n",i,j);
			}
			else if(i<m-1&&j==n-1)
			{
				if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j-1]&&s[i][j]>=s[i-1][j])
					printf("%d %d\n",i,j);
			}
			else if(i==m-1&&n==0)
			{
				if(s[i][j]>=s[i-1][j]&&s[i][j]>=s[i][j+1])
					printf("%d %d\n",i,j);
			}
			else if(i==m-1&&j<n-1)
			{
				if(s[i][j]>=s[i-1][j]&&s[i][j]>=s[i][j+1]&&s[i][j]>=s[i][j-1])
					printf("%d %d\n",i,j);
			}
			else if(i==m-1&&j==n-1)
			{
				if(s[i][j]>=s[i-1][j]&&s[i][j]>=s[i][j-1])
					printf("%d %d\n",i,j);
			}
}
int panduan(int a,int b, int c,int d,int e);
int panduan(int a,int b, int c,int d,int e){
    int s=0;
    if(e>=a&&e>=b&&e>=c&&e>=d){
        s=1;
    }
    return s;
}
int main(){
    int m,n,i,j;
    scanf("%d %d",&m,&n);
    int dikuai[m+2][n+2];
    for(i=1;i<m+1;i++){
        for(j=1;j<n+1;j++){
            scanf("%d",&dikuai[i][j]);
        }
    }
    for(j=0,i=0;i<m+2;i++){
        dikuai[i][j]=0;
    }
    for(j=n+1,i=0;i<m+2;i++){
        dikuai[i][j]=0;
    }
    for(j=0,i=m+1;j<n+2;j++){
        dikuai[i][j]=0;
    }
    for(j=0,i=0;j<n+2;j++){
        dikuai[i][j]=0;
    }
    for(i=1;i<m+1;i++){
        for(j=1;j<n+1;j++){
           if(panduan(dikuai[i-1][j],dikuai[i+1][j],dikuai[i][j-1],dikuai[i][j+1],dikuai[i][j])==1){
               printf("%d %d\n",i-1,j-1);
           }
        }
    }
    return 0;
    
}
/*
 * 11.cpp
 *
 *  Created on: 2010-11-20
 *      Author: jsgl
 */

int main()
{
	int a,b,x[22][22];
	cin>>a>>b;
	for ( int i=0 ;i<=a+1; i++ )
			for ( int j=0;j<=b+1;j++ )
				x[i][j]=-1;
	for ( int i=1 ;i<=a; i++ )
		for ( int j=1;j<=b;j++ )
			cin>>x[i][j];
	//cout<<x[4][0]<<endl;
//	for ( int i=1 ;i<=a; i++ )
//			for ( int j=1;j<=b;j++ )
//				cout<<x[i][j];
	for ( int k=1 ;k<=a; k++ )
			for ( int l=1;l<=b;l++ )
			{
				if ( (x[k][l]>=x[k-1][l])&&(x[k][l]>=x[k+1][l])&&(x[k][l]>=x[k][l-1])&&(x[k][l]>=x[k][l+1]))
				{
					//cout<<x[k][l]<<endl;
					cout<<k-1<<' '<<l-1<<endl;
				}
			}
	return 0;
}
int main(int argc, char* argv[])
{   
    int m,n,a[30][30],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++)
                {
                    if (i==0)
                    {
                     if (j==0&&a[0][0]>=a[0][1]&&a[0][0]>=a[1][0])
                       printf ("0 0\n");
                     if (j<n-1&&j>0)
                     {
                          if (a[0][j]>=a[0][j+1]&&a[0][j]>=a[0][j-1]&&a[0][j]>=a[1][j])
                          printf ("0 %d\n",j);
                          }
                      if (j==n-1)
                     {
                          if (a[0][j]>=a[0][j-1]&&a[0][j]>=a[1][j])
                          printf ("0 %d\n",j);
                          }
                          }
                if (i<(m-1)&&i>=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<n-1&&j>0)
                       {
                            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,j);
                            }
                       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);
                                 }
                                 }
                    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][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][j-1]&&a[i][j]>=a[i-1][j])
                                  printf ("%d %d\n",i,j);
                                  }
                                  }
                                  }
                                  }
                                  scanf ("%d",&i);
                                  return 0;
                                  }
int main(int argc, char* argv[])
{
	int m,n,a[20][20],b[24][24],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+2;i++)
	{
		for (j=0;j<n+2;j++)
		{
			b[i][j]=0;
		}
	}
	for (i=0;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			b[i+1][j+1]=a[i][j];
		}
	}
	for (i=0;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			if (b[i+1][j+1]+1>b[i][j+1]&&b[i+1][j+1]+1>b[i+1][j]&&b[i+1][j+1]+1>b[i+1][j+2]&&b[i+1][j+1]+1>b[i+2][j+1])
			{
				printf("%d %d\n",i,j);
			}
		}
	}


	
	
	return 0;


	
}
int main(){
 int s[20][20];
 int m,n;
 scanf("%d%d",&m,&n);
 for(int i=0;i<=m-1;i++){
	 for(int j=0;j<=n-1;j++){
		 scanf("%d",&s[i][j]);
	 }
 }
 for(int a=0;a<=m-1;a++){
	 for(int b=0;b<=n-1;b++){
		 if(a==0){
			 if(b==0){
				 if(s[a][b]>=s[a][b+1]&&s[a][b]>=s[a+1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }else if(b<=n-2){
				 if(s[a][b]>=s[a][b+1]&&s[a][b]>=s[a][b-1]&&s[a][b]>=s[a+1][b]){
                      printf("%d %d\n",a,b);
				 }
			 }else if(b==n-1){
				 if(s[a][b]>=s[a][b-1]&&s[a][b]>=s[a+1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }
		 }else if(a!=0&&a!=m-1){
			 if(b==0){
				 if(s[a][b]>=s[a+1][b]&&s[a][b]>=s[a-1][b]&&s[a][b]>=s[a][b+1]){
					 printf("%d %d\n",a,b);
				 }
			 }else if(b<=n-2){
				 if(s[a][b]>=s[a][b+1]&&s[a][b]>=s[a][b-1]&&s[a][b]>=s[a+1][b]&&s[a][b]>=s[a-1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }else if(b==n-1){
				 if(s[a][b]>=s[a][b-1]&&s[a][b]>=s[a-1][b]&&s[a][b]>=s[a+1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }
		 }else{
			 if(b==0){
				 if(s[a][b]>=s[a][b+1]&&s[a][b]>=s[a-1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }else if(b!=n-1){
				 if(s[a][b]>=s[a][b-1]&&s[a][b]>=s[a][b+1]&&s[a][b]>=s[a-1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }else{
				 if(s[a][b]>=s[a][b-1]&&s[a][b]>=s[a-1][b]){
					 printf("%d %d\n",a,b);
				 }
			 }
		 }
	 }
 }





		 
  

 return 0;}
int main()
{ int a[100][100],i=0,j=0,m,n;
	scanf("%d%d",&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) a[i][j]=0;
		else scanf("%d",&a[i][j]);
		}
	}
	


   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;
}
struct sha
{
	int gaodu;
	int x;
	int y;
	int shanding;
}mou[100][200],t;
int main()
{
	int m,n;
	cin>>m>>n;
	int i,j;
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>mou[i][j].gaodu;
			mou[i][j].x=i;
			mou[i][j].y=j;
			mou[i][j].shanding=0;
		}
	}
	for(i=0;i<=m+1;i++)
	{
		mou[i][n+1].gaodu=0;
		mou[i][0].gaodu=0;
	}
	for(i=0;i<=n+1;i++)
	{
		mou[m+1][i].gaodu=0;
		mou[0][i].gaodu=0;
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(mou[i][j].gaodu>=mou[i-1][j].gaodu&&mou[i][j].gaodu>=mou[i+1][j].gaodu&&mou[i][j].gaodu>=mou[i][j-1].gaodu&&mou[i][j].gaodu>=mou[i][j+1].gaodu)
				mou[i][j].shanding=1;
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(mou[i][j].shanding==1)
			{
				cout<<mou[i][j].x-1<<" "<<mou[i][j].y-1<<endl;
			}
		}
	}
return 0;
}
int main()
{
	int shandi[22][22]={0};
	int m,n;
	scanf("%d%d",&m,&n);
	int i,j;
	for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;j++)
		scanf("%d",&shandi[i][j]);
	}
	for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;j++)
		if(shandi[i][j]>=shandi[i-1][j]&&shandi[i][j]>=shandi[i+1][j]&&shandi[i][j]>=shandi[i][j-1]&&shandi[i][j]>=shandi[i][j+1])
			printf("%d %d\n",i-1,j-1);
	}	
	return 0;
}
int main(){
	int m, n, a[20][20]={0}, i, j, h;
	scanf("%d %d", &m, &n);
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d", &h);
			a[i][j]=h;
		}
	}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				if(i==0&&j==0){
					if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]){
					printf("%d %d\n", i, j);
				}
				}
					if(i==0&&j!=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);
				}
					}
						if(i!=0&&j==0){
							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);
				}
						}
						if(i!=0&&j!=0){
							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]){
								printf("%d %d\n", i, j);
				}
						}
			}
		}
				return 0;
			}
int main(){
    int m,n;
    scanf("%d%d",&m,&n);
    int gd[m+2][n+2];
    int a[1000],b[1000];
    int x=0;
   for(int i=0;i<m+2;i++){for(int k=0;k<n+2;k++){gd[i][k]=0;}}
    for(int i=1;i<=m;i++){for(int k=1;k<=n;k++){scanf("%d",&gd[i][k]);}}
     for(int i=1;i<=m;i++){for(int k=1;k<=n;k++)
 {if(gd[i][k]>=gd[i-1][k]&&gd[i][k]>=gd[i+1][k]&&gd[i][k]>=gd[i][k+1]&&gd[i][k]>=gd[i][k-1])
 {a[x]=i;b[x]=k;x++;}
     }
     }
     
    for(int i=0;i<x;i++){ printf("%d %d\n",a[i]-1,b[i]-1);}
    return 0;
    
}
int main()
{
        int m,n,i,j;
	int a[22][22];

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

    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]))
	    	 printf("%d %d\n",i-1,j-1);
	}
    }
    return 0;
}
main(){
    int m,n;
    int x,y,x1,x2,y1,y2;
    int s[M][N],a[M][N]={0};
    scanf("%d %d",&m, &n);
    for(y=0;y<m;y++){
		for(x=0;x<n;x++){
			scanf("%d",&s[y][x]);
        }
    }
    for(y=0;y<m;y++){
        a[y][n-1]=s[y][n-1];
        for(x1=0;x1<n-1;x1++){  
               if(s[y][x1]>=s[y][x1+1]){
                       a[y][x1]=s[y][x1];
                       }
               }
		for(x2=1;x2<n;x2++){    
               if(s[y][x2]<s[y][x2-1]){
                       a[y][x2]=0;
                       }
               }
	}
	for(x=0;x<n;x++){
		for(y1=0;y1<m-1;y1++){  
               if(s[y1][x]<s[y1+1][x]){ 
                     a[y1][x]=0;
                     }
               }
		for(y2=1;y2<m;y2++){    
               if(s[y2][x]<s[y2-1][x]){
                     a[y2][x]=0;
                     }
               }
        }
	for(y=0;y<m;y++){
		for(x=0;x<n;x++){
              if(a[y][x]!=0){          
                      printf("%d %d\n",y,x);
                      }
              }
	    }
    return 0; 
}
void main()
{
int m,n,i,j,temp1,temp2;
scanf("%d %d",&m,&n);
int a[30][30];
for(i=0;i<30;i++)
{
	for(j=0;j<30;j++)
	a[i][j]=0;
}
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][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
	{	
		temp1=i-1;
		temp2=j-1;
		printf("%d %d\n",temp1,temp2);
	}
}
}
int main()
{
	int m,n;
	scanf("%d %d",&m,&n);
	int i=0,j=0;
	int **pp;
	pp=(int **)malloc(sizeof (int *)*(m+2));
	for(i=0;i<m+2;i++)
    {
        pp[i]=(int *)malloc(sizeof (int)*(n+2));
	}    
	for(i=0;i<m+2;i++)
	for(j=0;j<n+2;j++)
	{
		if((i*j)!=0&&i!=(m+1)&&j!=(n+1))
		scanf("%d",&pp[i][j]);
		else
		pp[i][j]=0;
	}
	int k=0;
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(pp[i][j]>=pp[i-1][j])
			k=k+1;
			if(pp[i][j]>=pp[i+1][j])
			k=k+1;
			if(pp[i][j]>=pp[i][j-1])
			k=k+1;
			if(pp[i][j]>=pp[i][j+1])
			k=k+1;
			if(k==4)
			printf("%d %d\n",i-1,j-1);
			k=0;	
		}	
	}
	for(i=0;i<m;i++)
    free(pp[i]);
    free(pp);
	return 0; 	
}