semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//*****************************
//*???2011?1?9?         *
//*??????               *
//*?????3                *   
//*****************************
int main()//???
{//?????
	int m=0,n=0;
	int gaocheng[100][100];
	cin>>m>>n;
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			cin>>gaocheng[i][j];
	int x=0,y=0;
	for(x=0;x<m;x++)
	{
		for(y=0;y<n;y++)
		{
			if(x==0)
			{
				if(y==0)
				{
					if(gaocheng[x][y]>=gaocheng[x+1][y]&&gaocheng[x][y]>=gaocheng[x][y+1])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
				else if(y==n-1)
				{
					if(gaocheng[x][y]>=gaocheng[x+1][y]&&gaocheng[x][y]>=gaocheng[x][y-1])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
				else
				{
					if(gaocheng[x][y]>=gaocheng[x+1][y]&&gaocheng[x][y]>=gaocheng[x][y+1]&&gaocheng[x][y]>=gaocheng[x][y-1])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
			}
			else if(x==m-1)
			{
				if(y==0)
				{
					if(gaocheng[x][y]>=gaocheng[x-1][y]&&gaocheng[x][y]>=gaocheng[x][y+1])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
				else if(y==n-1)
				{
					if(gaocheng[x][y]>=gaocheng[x-1][y]&&gaocheng[x][y]>=gaocheng[x][y-1])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
				else
				{
					if(gaocheng[x][y]>=gaocheng[x-1][y]&&gaocheng[x][y]>=gaocheng[x][y+1]&&gaocheng[x][y]>=gaocheng[x][y-1])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
			}
			else
			{
				if(y==0)
				{
					if(gaocheng[x][y]>=gaocheng[x-1][y]&&gaocheng[x][y]>=gaocheng[x][y+1]&&gaocheng[x][y]>=gaocheng[x+1][y])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
				else if(y==n-1)
				{
					if(gaocheng[x][y]>=gaocheng[x-1][y]&&gaocheng[x][y]>=gaocheng[x][y-1]&&gaocheng[x][y]>=gaocheng[x+1][y])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
				else
				{
					if(gaocheng[x][y]>=gaocheng[x-1][y]&&gaocheng[x][y]>=gaocheng[x][y+1]&&gaocheng[x][y]>=gaocheng[x][y-1]&&gaocheng[x][y]>=gaocheng[x+1][y])
						cout<<x<<" "<<y<<endl;
					else continue;
				}
			}
		}
	}
	return 0;
}//?????
int main() {
    int m,n,a,b;
    scanf("%d %d",&m,&n);
    int sz[m+2][n+2];
    for(a=0,b=0;b<n+2;b++) {
        sz[a][b]=0;
    }
    for(a=m+1,b=0;b<n+2;b++) {
        sz[a][b]=0;
    }
    for(a=1,b=0;a<m+1;a++) {
        sz[a][b]=0;
    }
    for(a=1,b=n+1;a<m+1;a++) {
        sz[a][b]=0;
    }
    for(a=1;a<=m;a++) {
        for(b=1;b<=n;b++) {
            scanf("%d",&(sz[a][b]));
        }
    }
    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,j,g=0,t,h,k,l;
    int a[22][22]={0},b[100],c[100];
   scanf("%d %d",&n,&m);

for(i=1;i<=n;i++) {
		 for(j=1;j<=m;j++) {
			 scanf("%d",&a[i][j]);
		 }
	}
   for(i=1;i<=n;i++) {
		for (j=1;j<=m;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])  )
		   {b[g]=i-1; 
		    c[g]=j-1; 
			g++;
		   }
		}
	}
for(l=0;l<g;l++) {
        for(k=0;k<g-1;k++){
			if (b[k]>b[k+1])
			{t=b[k];   b[k]=b[k+1];    b[k+1]=t;
			h=c[k];   c[k]=c[k+1];    c[k+1]=h;}
			if(b[k]==b[k+1]&&c[k]>c[k+1])  {h=c[k]; c[k]=c[k+1]; c[k+1]=h;}
		}
	}

for(l=0;l<g;l++){
	printf("%d %d\n",b[l],c[l]);
}

	return 0;
}
void main()
{
	int a[100][100],i,j,b,n,m;
	scanf("%d%d",&m,&n);
	for(i=0;i<=m-1;i++)
	{
		for(j=0;j<=n-1;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<=m-1;i++)
	{
		for(j=0;j<=n-1;j++)
		{
			if(i!=0&&j!=0&&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);
			else if(i!=0&&j==0&&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&&j!=0&&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==0&&j==0&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])printf("%d %d\n",i,j);
			else if(i==m-1&&j==n-1&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])printf("%d %d\n",i,j);
			else if(i==m-1&&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==n-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 b=1;
		}
	}
}
double mou[20][20];
int m,n;
int judge(int x,int y)
{
	double sum=0,s=0;
	if(x+1<=m)
	{
		if(mou[x+1][y]<=mou[x][y])
		sum++;
		s++;
	}
	if(x-1>=0)
	{
		if(mou[x-1][y]<=mou[x][y])
		sum++;
		s++;
	}
	if(y+1<=n)
	{
		if(mou[x][y+1]<=mou[x][y])
		sum++;
		s++;
	}
	if(y-1>=0)
	{
		if(mou[x][y-1]<=mou[x][y])
		sum++;
		s++;
	}
	if(sum==s)
	return 1;
	else
	return 0;
}
int main()
{
	cin>>m>>n;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>mou[i][j];
		}
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(judge(i,j))
			cout<<i<<" "<<j<<endl;
		}
	}
	return 0;
}
int main()
{
	int m,n,a[22][22]={0};
	int i,j,t;
	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++)
		{
			t=a[i][j];
			if(t>=a[i-1][j]&&t>=a[i][j-1]&&t>=a[i+1][j]&&t>=a[i][j+1])
				printf("%d %d\n",i-1,j-1);
		}
	}
	return 0;
}
int main()
{
	int a[60][60]={0},m,n,i,j,i1,j1,b[60][60]={0};
	cin>>m>>n;
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(i1=1;i1<=m;i1++)
	{
		for(j1=1;j1<=n;j1++)
		{
			if(a[i1][j1]>=a[i1][j1-1]&&a[i1][j1]>=a[i1][j1+
				1]&&a[i1][j1]>=a[i1-1][j1]&&a[i1][j1]>=a[i1+1][j1])
			{
				b[i1][j1]=1;
			}
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(b[i][j]==1)
			{
				cout<<i-1<<" "<<j-1<<endl;
			}

		}
	}
	return 0;
}
int main()
{
	int x, y, sz1[number][number], j, l;
	scanf("%d%d", &y, &x);
	for(j=0;j<y;j++)
	{
		for(l=0;l<x;l++)
			scanf("%d", &(sz1[j][l]));
	}	
	for(j=0;j<y;j++)
	{
		for(l=0;l<x;l++)
		{
			if(j!=0&&l!=0&&j!=y-1&&l!=x-1)
			{
			    if(sz1[j][l]>=sz1[j+1][l]&&sz1[j][l]>=sz1[j-1][l]&&sz1[j][l]>=sz1[j][l-1]&&sz1[j][l]>=sz1[j][l+1])
			        printf("%d %d\n", j, l);
			}
			else if(j==0&&l!=0&&l!=x-1)
			{
				if(sz1[j][l]>=sz1[j+1][l]&&sz1[j][l]>=sz1[j][l-1]&&sz1[j][l]>=sz1[j][l+1])
			        printf("%d %d\n", j, l);
			}
			else if(j==0&&l==0)
			{
				if(sz1[j][l]>=sz1[j+1][l]&&sz1[j][l]>=sz1[j][l+1])
			        printf("%d %d\n", j, l);
			}
			else if(j==0&&l==x-1)
			{
				if(sz1[j][l]>=sz1[j+1][l]&&sz1[j][l]>=sz1[j][l-1])
			        printf("%d %d\n", j, l);
			}
			else if(l==0&&j!=y-1)
			{
				if(sz1[j][l]>=sz1[j+1][l]&&sz1[j][l]>=sz1[j-1][l]&&sz1[j][l]>=sz1[j][l+1])
			        printf("%d %d\n", j, l);
			}
			else if(l==0&&j==y-1)
			{
				if(sz1[j][l]>=sz1[j-1][l]&&sz1[j][l]>=sz1[j][l+1])
			        printf("%d %d\n", j, l);
			}
			else if(j==y-1&&l!=y-1)
			{
				if(sz1[j][l]>=sz1[j][l+1]&&sz1[j][l]>=sz1[j-1][l]&&sz1[j][l]>=sz1[j][l-1])
			        printf("%d %d\n", j, l);
			}
			else if(j==y-1&&l==y-1)
			{
				if(sz1[j][l]>=sz1[j-1][l]&&sz1[j][l]>=sz1[j][l-1])
			        printf("%d %d\n", j, l);
			}
			else
			{
				if(sz1[j][l]>=sz1[j+1][l]&&sz1[j][l]>=sz1[j-1][l]&&sz1[j][l]>=sz1[j][l-1])
			        printf("%d %d\n", j, l);
			}
		}
	}
	return 0;
}
int main()
{
    int m,n;
    cin>>m>>n;
    int a[25][25];
    for(int i=1;i<m+1;i++)
    {
            for(int j=1;j<n+1;j++)
            {
                    cin>>a[i][j];
            }
    }
    for(int i=1;i<m+1;i++)
    {
            a[i][0]=a[i][1];
            a[i][n+1]=a[i][n];
    }
    for(int j=1;j<n+1;j++)
    {
            a[0][j]=a[1][j];
            a[m+1][j]=a[m][j];
    }
    for(int i=1;i<m+1;i++)
    {
            for(int j=1;j<n+1;j++)
            {
                    if(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]<=a[i][j])
                    {
                       cout<<i-1<<" "<<j-1<<endl;
                    }
            }
    }
    return 0;
}
int main()
{
	int a[22][22]={0};
	int num=0;
	int hang[100]={0},lie[100]={0};
	int m,n;
	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][j-1]&&a[i][j]>=a[i][j+1]
			&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j])
			{
				num++;
				hang[num]=i-1;
				lie[num]=j-1;
			}
		}
	}

	for(int i=1;i<num;i++)
	{
		for(int j=1;j<=num-i;j++)
		{
			if(hang[j]>hang[j+1])
			{
				int t1=hang[j];
				hang[j]=hang[j+1];
				hang[j+1]=t1;
				int t2=lie[j];
				lie[j]=lie[j+1];
				lie[j+1]=t2;
			}
		}
	}

	for(int i=1;i<=num;i++)
		cout<<hang[i]<<" "<<lie[i]<<endl;
	return 0;
}
int main(){
int m,n,i,j,sz[22][22],a;
scanf("%d %d",&m,&n);
for(i=1;i<=m;i++){
                 for(j=1;j<=n;j++){
                                  scanf("%d",&sz[i][j]);
                                  }
                 }
                 for(i=0;i<=m+1;i++){
                                  sz[i][0]=0;
                                  sz[i][n+1]=0;
                                  }
                                  for(j=0;j<=n+1;j++){
                                                   sz[0][j]=0;
                                                   sz[m+1][j]=0;
                                                   }
                                                   for(i=1;i<=m;i++){
                                                                    for(j=1;j<=n;j++){
                                                                                     a=sz[i][j];
                                                                                     if(a>=sz[i][j-1]&&a>=sz[i][j+1]&&a>=sz[i-1][j]&&a>=sz[i+1][j]){
                                                                                                                                                    printf("%d %d\n",i-1,j-1);
                                                                                                                                                    }
                                                                                     }
                                                                    }
                 
                                  return 0;                              
}
int main()
{
	int i,j,n,m,a[100][100];
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			scanf("%d",&a[i][j]);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(i==0||(a[i][j]>=a[i-1][j]&&i>0))
			{
				if(i==n-1||(a[i][j]>=a[i+1][j]&&i<n-1))
				{
					if(j==0||(a[i][j]>=a[i][j-1]&&j>0))
					{
						if((j==m-1||a[i][j]>=a[i][j+1]&&j<m-1))
							printf("%d %d\n",i,j);
					}
				}
			}
		}
	}
}
int main(){
    int m,n,a,b;
    int sz[30][30]={0};
    scanf("%d %d",&m,&n);
    for(a=1;a<=m;a++){
                      for(b=1;b<=n;b++){scanf("%d",&sz[a][b]);}}
        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 a[20][20];
	int b[400];
	int d[400];
	int m,n,j;
	scanf("%d %d",&m,&n);
	int i,k;
	j=0;
	for(i=0;i<m;i++){
		for(k=0;k<n;k++){
			scanf("%d",&a[i][k]);
		}
	}
	for(i=0;i<m;i++){
		for(k=0;k<n;k++){
			if(i==0){
				if(k==0){
					if(a[i][k]>=a[i+1][k]&&a[i][k]>=a[i][k+1]){
						b[j]=i;
						d[j]=k;
						j=j+1;
					}
				}
				else if(k==n-1){
					if(a[i][k]>=a[i][k-1]&&a[i][k]>=a[i+1][k]){
						b[j]=i;
						d[j]=k;
						j=j+1;
					}
				}else{
					if(a[i][k]>=a[i][k-1]&&a[i][k]>=a[i+1][k]&&a[i][k]>=a[i][k+1]){
                        b[j]=i;
						d[j]=k;
						j=j+1;
					}
				}
			}
			else if(i==m-1){
				if(k==0){
					if(a[i][k]>=a[i-1][k]&&a[i][k]>=a[i][k+1]){
						b[j]=i;
						d[j]=k;
						j=j+1;
					}
				}
				else if(k==n-1){
					if(a[i][k]>=a[i-1][k]&&a[i][k]>=a[i][k-1]){
						b[j]=i;
						d[j]=k;
						j=j+1;
					}
				}else{
					if(a[i][k]>=a[i-1][k]&&a[i][k]>=a[i][k+1]&&a[i][k]>=a[i][k-1]){
                        b[j]=i;
						d[j]=k;
						j=j+1;
					}
				}
			}
			else if(k==0){
				if(a[i][k]>=a[i-1][k]&&a[i][k]>=a[i+1][k]&&a[i][k]>=a[i][k+1]){
					b[j]=i;
					d[j]=k;
					j=j+1;
				}
			}
			else if(k==n-1){
				if(a[i][k]>=a[i][k-1]&&a[i][k]>=a[i+1][k]&&a[i][k]>=a[i-1][k]){
					b[j]=i;
					d[j]=k;
					j=j+1;
				}
			}else{
				if(a[i][k]>=a[i+1][k]&&a[i][k]>=a[i-1][k]&&a[i][k]>=a[i][k-1]&&a[i][k]>=a[i][k+1]){
					b[j]=i;
				    d[j]=k;
				    j=j+1;
				}
			}
		}
	}
	int h;
	for(h=1;h<=j;h++){
		int e,c;
		for(i=0;i<j-h;i++){
			if(b[i]>b[i+1]){
				e=b[i+1];
				c=d[i+1];
                d[i+1]=d[i];
				b[i+1]=b[i];
				b[i]=e;
				d[i]=c;
			}
		}
	}
	for(i=0;i<j;i++){
		printf("%d %d\n",b[i],d[i]);
	}
	return 0;
}
int main(){
    int m,n,sz[20][20],i,j;
	scanf("%d%d",&m,&n);
    for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(i==0&&j==0){
				if(sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1])
					printf("%d %d\n",i,j);
			}else if(i==0&&j==n-1){
                if(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&&j==0){
				if(sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j+1])
                    printf("%d %d\n",i,j);
			}else if(i==m-1&&j==n-1){
				if(sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j-1])
                    printf("%d %d\n",i,j);
			}else if(i==0&&j!=0&&j!=n-1){
				if(sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1])
					printf("%d %d\n",i,j);
			}else if(i==m-1&&j!=0&&j!=n-1){
				if(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,j);
			}else if(j==0&&i!=0&&i!=m-1){
				if(sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1])
					printf("%d %d\n",i,j);
			}else if(j==n-1&&i!=0&&i!=m-1){
				if(sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j-1])
					printf("%d %d\n",i,j);
			}else{
			    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])
				    printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
}
/*
 * intergratedexercise1.21.cpp
 *
 *  Created on: 2013-12-28
 *      Author: st
 */
int main()
{
	int hill[22][22];
	memset(hill,0,sizeof(hill));
	int m,n;
	cin>>m>>n;
	int i,j;
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			cin>>hill[i][j];
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			if(hill[i][j]>=hill[i][j-1]&&hill[i][j]>=hill[i][j+1]&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i+1][j])
				cout<<i-1<<' '<<j-1<<endl;

}
int main(int argc, char* argv[])
{
	int m,n,i,j,x[20][20],h[400],z[400],t=0;
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)for(j=0;j<n;j++)scanf("%d",&x[i][j]);
	for(i=0;i<m;i++)
	{
		if(i==0)for(j=0;j<n;j++)
		{
			if(j==0)       {if(x[i][j]>=x[i+1][j]&&x[i][j]>=x[i][j+1]){h[t]=i;z[t]=j;t++;}}
			else if(j<n-1) {if(x[i][j]>=x[i][j-1]&&x[i][j]>=x[i][j+1]&&x[i][j]>=x[i+1][j]){h[t]=i;z[t]=j;t++;}}
			else           {if(x[i][j]>=x[i+1][j]&&x[i][j]>=x[i][j-1]){h[t]=i;z[t]=j;t++;}}
		}
		else if(i<m-1)for(j=0;j<n;j++)
		{
			if(j==0)        {if(x[i][j]>=x[i-1][j]&&x[i][j]>=x[i+1][j]&&x[i][j]>=x[i][j+1]){h[t]=i;z[t]=j;t++;}}
			else if(j<n-1)  {if(x[i][j]>=x[i][j-1]&&x[i][j]>=x[i][j+1]&&x[i][j]>=x[i-1][j]&&x[i][j]>=x[i+1][j]){h[t]=i;z[t]=j;t++;}}
			else            {if(x[i][j]>=x[i-1][j]&&x[i][j]>=x[i+1][j]&&x[i][j]>=x[i][j-1]){h[t]=i;z[t]=j;t++;}}
		}
		else  for(j=0;j<n;j++)
		{
			if(j==0)        {if(x[i][j]>=x[i-1][j]&&x[i][j]>=x[i][j+1]){h[t]=i;z[t]=j;t++;}}
			else if(j<n-1)  {if(x[i][j]>=x[i-1][j]&&x[i][j]>=x[i][j-1]&&x[i][j]>=x[i][j+1]){h[t]=i;z[t]=j;t++;}}
			else            {if(x[i][j]>=x[i-1][j]&&x[i][j]>=x[i][j-1]){h[t]=i;z[t]=j;t++;}}
		}
	}
	for(i=0;i<t;i++)
		printf("%d %d\n",h[i],z[i]);
	return 0;
}
int main(){
	int m,n;
	cin>>m>>n;
	int a[m][n];
	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++){
			if(((i-1>=0)&&(a[i-1][j]<=a[i][j])||(i-1<0))&&
					((i+1<m)&&(a[i+1][j]<=a[i][j])||(i+1>=m))&&
					((j-1>=0)&&(a[i][j-1]<=a[i][j])||(j-1<0))&&
					((j+1<n)&&(a[i][j+1]<=a[i][j])||(j+1>=n))
					)
				cout<<i<<" "<<j<<endl;
		}
	return 0;
}
int main()
{
	int m,n,a[22][22]={0},i,j;
	cin>>m>>n;
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
			cin>>a[i][j];
		a[i][0]=a[i][1];
		a[i][n+1]=a[i][n];
	}
	for(j=1;j<=n;j++)
	{
		a[0][j]=a[1][j];
		a[m+1][j]=a[m][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,i,j,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==0&&j==0)
            {
                if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
                    cout << i << " " << j <<endl;
            }
            if(i==0&&j<n-1&&j>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;
            }
            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;
            }
            if(i<m-1&&i>0)
            {
                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])
                        cout << i << " " << j <<endl;
                }
                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])
                        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;
                }
            }
            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;
            }
            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;
            }
        }
    }
     if(a[m-1][n-1]>=a[m-2][n-1]&&a[m-1][n-1]>=a[m-1][n-2])
                cout << m-1 << " " << n-1 <<endl;
           
    return 0;
}
int main()
{
		int m,n,a[500][500];
		cin>>m>>n;

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

}
void top(int m,int n,int a[21][21])
{
	int i,j;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(((i>0&&a[i][j]>=a[i-1][j])||i==0)&&((i<m-1&&a[i][j]>=a[i+1][j])||i==m-1)&&((j>0&&a[i][j]>=a[i][j-1])||j==0)&&((j<n-1&&a[i][j]>=a[i][j+1])||j==n-1))
				cout<<i<<" "<<j<<endl;
		}
	}
}
int main()
{
	int m,n,num[21][21]={0};
	int i,j;
	cin>>m>>n;
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			cin>>num[i][j];
	top(m,n,num);
	return 0;
}
int main()
{
	int m,n,i,j;
	int data[30][30];
	scanf("%d%d",&m,&n);
	for( i = 1; i <= m; i++ )
		for( j = 1 ; j <= n; j++ )
			scanf("%d",&data[i][j]);
	for( i = 1 ; i <= m; i++ )
		for( j = 1; j <= n; j++ )
		{
			int flag = 1;
			if( i > 1 && data[i-1][j] > data[i][j] )
				flag = 0;
			if( j > 1 && data[i][j-1] > data[i][j] )
				flag = 0;
			if( j < n && data[i][j+1] > data[i][j] )
				flag = 0;
			if( i < m && data[i+1][j] > data[i][j] )
				flag = 0;
			if( flag )
				printf("%d %d\n",i-1,j-1);
		}
		return 0;

}
int main(){
	int i,k,j,m,n,e=0;
	int sz[102][102]={0};
	int s[100][2];
	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]){
				s[e][0]=i-1;
				s[e][1]=j-1;
				e++;
			}
		}
	}
	for(i=0;i<e;i++){
		printf("%d %d\n",s[i][0],s[i][1]);}
	return 0;
	
}
int h[25][25] = {0};
int f(int x, int y)
{
	if (h[x][y] >= h[x - 1][y] && h[x][y] >= h[x + 1][y] && h[x][y] >= h[x][y - 1] && h[x][y] >= h[x][y + 1])
		return 1;
	else
		return 0;
}
int main()
{
	int m, n, i, j;
	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 (f(i, j))
				cout << i - 1 << " " << j - 1 << endl;
	return 0;
}
int main()
{
	int m,n,a[25][25];
	cin>>m>>n;
	memset(a,0,sizeof(a));
	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,k=0;
  int ht[40][40];
  int aa[400];
  int bb[400];
   scanf("%d%d",&m,&n); 
   for(i=0;i<=m;i++){ht[i][0]=0;}
   for(j=0;j<=n;j++){ht[m+1][j]=0;}
   for(i=m+1;i>0;i--){ht[i][n+1]=0;}
   for(j=n+1;j>0;j--){ht[0][j]=0;}
   
   for(i=1;i<=m;i++){
     for(j=1;j<=n;j++){
        scanf("%d",&ht[i][j]); } }   
   for(i=1;i<=m;i++){
       for(j=1;j<=n;j++){
          if(ht[i][j]>=ht[i-1][j]&&ht[i][j]>=ht[i+1][j]&&ht[i][j]>=ht[i][j-1]&&ht[i][j]>=ht[i][j+1]){
           printf("%d %d\n",i-1,j-1);
            }}}   
   
     return 0; 
}
int main()
{
	int m,n,i,j,a[25][25],x[25][25];
	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) {if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]) x[i][j]=1;}
			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]) x[i][j]=1;}
			if(i==0&&j==n-1) {if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]) x[i][j]=1;}
			if(i!=0&&i!=m-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]) x[i][j]=1;}
			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-1][j]&&a[i][j]>=a[i][j-1]) x[i][j]=1;}
			if(i!=0&&i!=m-1&&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]) x[i][j]=1;}
			if(i==m-1&&j==0) {if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]) x[i][j]=1;}
			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]) x[i][j]=1;}
			if(i==m-1&&j==n-1) {if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j]) x[i][j]=1;}
		}
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(x[i][j]==1) printf("%d %d\n",i,j);
		}
	}
	return 0;
}