semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
      int a[20][20],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]);
      for(i=0;i<m;i++)
      for(j=0;j<n;j++)
      {
         if(i==0)
         {
           if(j==0)
           {if(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)
           {if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1])printf("%d %d\n",i,j);}
           else
           {if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])printf("%d %d\n",i,j);}
         }
         else
         if(i==m-1)
         {
           if(j==0)
           {if(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)
           {if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])printf("%d %d\n",i,j);}
           else
           {if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])printf("%d %d\n",i,j);}
         }
         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])printf("%d %d\n",i,j);}
            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])printf("%d %d\n",i,j);}
           else
           {if(a[i][j]>=a[i-1][j]&&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);}
         }
      }
}
int main(){
	int m,n,i,j;
	cin>>m;
	cin>>n;
	int a[m][n];
	for(i=0;i<=m-1;i++)
		for(j=0;j<=n-1;j++)
			cin>>a[i][j];
	for(i=0;i<=m-1;i++)
		for(j=0;j<=n-1;j++)
		{
			if((i!=0)&&(i!=m-1)&&(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;
			}
			else if((i==0)&&(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!=0)&&(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!=0)&&(i!=m-1)&&(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]))
					cout<<i<<" "<<j<<endl;
			}
			else if((i!=0)&&(i!=m-1)&&(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]))
					cout<<i<<" "<<j<<endl;
			}
			else if((i==0)&&(i!=m-1)&&(j==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)&&(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)&&(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)&&(j==n-1))
			{
				if((a[i][j]>=a[i-1][j])&&(a[i][j]>=a[i][j-1]))
					cout<<i<<" "<<j<<endl;
			}
		}
	return 0;

}
int main(){
int m,n,i,j,A[20][20];
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++){
if(i==0){
if(A[0][0]>=A[0][1]&&A[0][0]>=A[1][0])printf("0 0\n");
for(j=1;j<m-1;j++){
if(A[0][j]>=A[0][j-1]&&A[0][j]>=A[1][j]&&A[0][j]>=A[0][j+1])
printf("0 %d\n",j);
}
if(A[0][m-1]>=A[0][m-2]&&A[0][m-1]>=A[1][m-1])printf("0 %d\n",m-1);}
else if(i!=0&&i!=n-1){
if(A[i][0]>=A[i-1][0]&&A[i][0]>=A[i+1][0]&&A[i][0]>=A[i][1])printf("%d 0\n",i);
for(j=1;j<m-1;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])
printf("%d %d\n",i,j);
}
if(A[i][m-1]>=A[i][m-2]&&A[i][m-1]>=A[i+1][m-1]&&A[i][m-1]>=A[i-1][m-1])printf("%d %d\n",i,m-1);}
else if(i==n-1){
if(A[n-1][0]>=A[n-2][0]&&A[n-1][0]>=A[n-1][1])printf("%d 0\n",n-1);
for(j=1;j<m-1;j++){
if(A[n-1][j]>=A[n-2][j]&&A[n-1][j]>=A[n-1][j-1]&&A[n-1][j]>=A[n-1][j+1])
printf("%d %d\n",i,j);}
if(A[n-1][m-1]>=A[n-1][m-2]&&A[n-1][m-1]>=A[n-2][m-1])printf("%d %d\n",n-1,m-1);

}
}
return 0;
}
void main()
{
	int m,n,i,j;
	scanf("%d %d",&m,&n);
	int a[23][22];
	for(j=0;j<=n;j=j+1)
	{
		a[0][j]=0;
		a[m+1][j]=0;
	}
	for(i=0;i<=m+1;i=i+1)
		a[i][n+1]=0;

	for(i=1;i<=m;i=i+1)
	{
		a[i][0]=0;
		for(j=1;j<=n;j=j+1)
			scanf("%d",&a[i][j]);
	}
	for(i=1;i<=m;i=i+1)
	{
		for(j=1;j<=n;j=j+1)
		{
			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);
		}
	}
}
int main()
{
    
   int m,n,i,j,u;
   cin>>m>>n;
   int a[m+2][n+2];
      for(i=0 ;i<m+2;i++)
       for(j=0; j<n+2;j++)
         a[i][j]=0;
     for(i=1 ;i<m+1;i++)
       for(j=1; j<n+1;j++)
         cin>>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])==4)
            cout<<i-1<<" "<<j-1<<endl;}
        
        return 0;
        }
void main()
{int i,j,m,n,flag,h[22][22]={0},*pa;
 scanf("%d%d",&m,&n);
 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++)
	 {flag=1;
	  pa=*(h+i)+j;
      if (*pa<h[i-1][j])
		  flag=0;
	  if (*pa<h[i+1][j])
		  flag=0;
	  if (*pa<h[i][j+1])
		  flag=0;
	  if (*pa<h[i][j-1])
		  flag=0;
	  if (flag==1)
		  printf("%d %d\n",i-1,j-1);
	 }
}
int main()
{
	int m,n,i,j,b,c;
	int a[20][20];
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i==0&&j==0)
			{
				if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
			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])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
			if(i==0&&j==n-1)
			{
                if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
			if(j==0&&i!=0&&i!=m-1)
			{
                if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
            if(j==0&&i==m-1)
			{
                if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
			
            if(j!=0&&j!=n-1&&i==m-1)
			{
                if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
            
            if(j==n-1&&i==m-1)
			{
                if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
            if(j==n-1&&i!=m-1&&i!=0)
			{
                if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j])
				{
                b=i;
                c=j;
					printf("%d %d\n",b,c);
				}
			}
			
            if(i!=0&&i!=m-1&&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]&&a[i][j]>=a[i-1][j])
			{
				b=i;
                c=j;
				printf("%d %d\n",b,c);
			}
			}  
		}
	}
	return 0;
}
int main()
{
	int hang,lie;
	cin>>hang>>lie;
	int a[20][20];
	for (int i1=0;i1<hang;i1++)
	{
		for (int j1=0;j1<lie;j1++)
		{
			cin>>a[i1][j1];  //:????
		} 
	}

	for (int i=0;i<hang;i++)
	{
		for (int j=0;j<lie;j++)   //:?????????????????continue
		{
			if ( (i-1)>=0 && a[i][j]<a[i-1][j])
				continue;
			if ( i+1<hang && a[i][j]<a[i+1][j])
				continue;
			if ( j-1>=0 && a[i][j]<a[i][j-1])
				continue;
			if ( j+1<lie && a[i][j]<a[i][j+1])
				continue;
			cout<<i<<" "<<j<<endl;
		}
	}
	return 0;
}
void main()
{
	int a[20][20],put[100][2];
	int m,n,i,j,k=0;
	scanf("%d%d",&m,&n);
    for(i=0;i<=m-1;i++)
		for(j=0;j<=n-1;j++)
			scanf("%d",&a[i][j]);
    if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0])
	{	
				put[k][0]=0;
			    put[k][1]=0;
		     	k++;
	}
		for(j=1;j<=n-2;j++)
			if(a[0][j]>=a[0][j+1]&&a[0][j]>=a[1][j]&&a[0][j]>=a[0][j-1])
	{	
				put[k][0]=0;
			    put[k][1]=j;
		     	k++;
	}
    if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1])
	{	
				put[k][0]=0;
			    put[k][1]=n-1;
		     	k++;
	}
    for(i=1;i<=m-2;i++)
	{	if(a[i][0]>=a[i][1]&&a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0])
	{	
				put[k][0]=i;
			    put[k][1]=0;
		     	k++;
	}
		for(j=1;j<=n-2;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])
			{	
				put[k][0]=i;
			    put[k][1]=j;
		     	k++;
			}
		}
		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])
	{	
				put[k][0]=i;
			    put[k][1]=n-1;
		     	k++;
	}
	}
if(a[m-1][0]>=a[m-1][1]&&a[m-1][0]>=a[m-2][0])
	{	
				put[k][0]=m-1;
			    put[k][1]=0;
		     	k++;
	}
		for(j=1;j<=n-2;j++)
			if(a[m-1][j]>=a[m-1][j+1]&&a[m-1][j]>=a[m-2][j]&&a[m-1][j]>=a[m-1][j-1])
	{	
				put[k][0]=m-1;
			    put[k][1]=j;
		     	k++;
	}
    if(a[m-1][n-1]>=a[m-1][n-2]&&a[m-1][n-1]>=a[m-2][n-1])
	{	
				put[k][0]=m-1;
			    put[k][1]=n-1;
		     	k++;
	}
   for(i=0;i<=k-1;i++)
	   printf("%d %d\n",put[i][0],put[i][1]);
}
int s[110][110];
int main(){
	int m,n,i,j;
	scanf("%d%d",&m,&n);
	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][j-1]
				&&s[i][j]>=s[i][j+1]
				&&s[i][j]>=s[i-1][j]
				&&s[i][j]>=s[i+1][j]){
				printf("%d %d\n",i-1,j-1);
			}
		}
	}
}
//???  ??? 1000010334 
int main()
{
    int m=0;  //?? ?? 
    int n=0;  //??  ?? 
    cin>>m;
    cin>>n;
    int h[22][22];  //???? 
    for(int i=0;i<22;i++)   //???????????0 
    {
      h[0][i]=0;
      h[i][0]=0;
      h[i][n+1]=0;
      h[m+1][i]=0;
    }
    
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>h[i][j];
        }
    }
    //????? 
    for(int i=1;i<=m;i++)  //????? 
    {
       for(int 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;
    int a[25][25];
    cin>>m>>n;
    for(int i=0;i<n+2;i++)
    {
            a[0][i]=0;
            a[m+1][i]=0;
    }
    for(int i=1;i<m+1;i++)
    {
            a[i][0]=0;
            a[i][n+1]=0;
            for(int j=1;j<n+1;j++)
            {
                    cin>>a[i][j];
            }
    }
    for(int i=1;i<m+1;i++)
    {
            for(int 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-1<<' '<<j-1<<endl;
            }
    }
    
    return 0;
}
int m,n,a[20][20];

int height(int i,int j)
{
	if(i<0||i>=m||j<0||j>=n)return -1;
	else return a[i][j];
}

void check(int i,int j)
{
	if(a[i][j]>=height(i-1,j)&&a[i][j]>=height(i+1,j)&&a[i][j]>=height(i,j-1)&&a[i][j]>=height(i,j+1))cout<<i<<' '<<j<<endl;
}

int main()
{
	int i,j;
	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++)check(i,j);
	return 0;
}
int 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&&j==0&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
		    printf("%d %d\n",i,j);
		else if(i==0&&j==(n-1)&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
		    printf("%d %d\n",i,j);
		else if(i==0&&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);
		else if(i==(m-1)&&j==0&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])
		    printf("%d %d\n",i,j);
		else if(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==(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(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 if(i==(m-1)&&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);
	
	
		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);
		}
	}
	return 0;
}
int m,n;
int height[40][40];
double average[40][40];

int main(){
    int i,j;
    scanf("%d%d",&m,&n);
    memset(average,0,sizeof(average));
    
    for (i=0;i<m;i++){
        for (j=0;j<n;j++) scanf("%d",&height[i][j]);
    }
    
    for (i=0;i<m;i++){
        for (j=0;j<n;j++){
            int count = 0,sum = 0;
            if (i>0) {
                sum += height[i-1][j];
                count++;
            }
            if (i<m-1) {
                sum += height[i+1][j];
                count++;
            }
            if (j>0) {
                sum += height[i][j-1];
                count++;
            }
            if (j<n-1) {
                sum += height[i][j+1];
                count++;
            }
            average[i][j] = (double) sum / count;
        }
    }
    
    for (i=0;i<m;i++){
        for (j=0;j<n;j++){
            double maxh;
            maxh = height[i][j];
            if (i>0 && height[i-1][j] > maxh) {
                maxh = height[i-1][j];
            }
            if (i<m-1 && height[i+1][j] > maxh) {
                maxh = height[i+1][j];
            }
            if (j>0 && height[i][j-1] > maxh) {
                maxh = height[i][j-1];
            }
            if (j<n-1 && height[i][j+1] > maxh) {
                maxh = height[i][j+1];
            }
            if (abs(maxh - (double)height[i][j]) < 0.000001) printf("%d %d\n",i,j);
        }
    }

    return 0;
}
int main()
{
	int m , n;
	int a[ 21 ][ 21 ];
	int i , j;
	cin >> m >> n;
	for ( i = 0 ; i <= m - 1 ; i++ )
	{
		for ( j = 0 ; j <= n - 1 ; 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 - 2 ; 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 ( j = 1 ; j <= m - 2 ; j++ )
	{
		if ( a[ j ][ 0 ] >= a[ j ][ 1 ] && a[j][0] >= a[j+1][0] && a[j][0] >= a[j - 1][0] )
		   cout << j << ' ' << 0 << endl;
	    for ( i = 1 ; i <= n - 2 ; i++ )
		{
		   if ( a[ j ][ i ] >= a[j][i-1] && a[j][i] >= a[j][i+1] && a[j][i] >= a[j+1][i] && a[j][i] >= a[j - 1][i] )
		   {
		     	cout << j << ' ' << i << endl;
		   }
		}
    	if ( a[ j ][ n - 1 ] >= a[ j ][ n - 2 ] && a[j][n - 1] >= a[j+1][n - 1]  && a[j][n - 1] >= a[j - 1][n - 1])
	    	cout << j << ' ' << 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 - 2 ; 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;
        int a[22][22];
        cin>>m>>n;
        for(i=0;i<=n+1;i++) a[m+1][i]=a[0][i]=0;
        for(i=0;i<=m+1;i++) a[i][n+1]=a[i][0]=0;
        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 mount[20][20], m, n, i, j, left, right, up, down;
	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 (j - 1 < 0)
				left = 1;
			else
				if (mount[i][j - 1] <= mount[i][j])
					left = 1;
				else
					left = 0;
			if (j + 1 == n)
				right = 1;
			else
				if (mount[i][j + 1] <= mount[i][j])
					right = 1;
				else
					right = 0;
			if (i - 1 < 0)
				up = 1;
			else
				if (mount[i - 1][j] <= mount[i][j])
					up = 1;
				else
					up = 0;
			if (i + 1 == m)
				down = 1;
			else
				if (mount[i + 1][j] <= mount[i][j])
					down = 1;
				else
					down = 0;
			if (left + right + up + down == 4)
				cout << i << " " << j << endl;
		}
	return 0;
}
int main(){
	int m,n,i,j,a[100][100],b,c,d,e,k;
	scanf("%d%d",&m,&n);
	for(i=0;i<m+2;i++){
		a[i][0]=0;
		a[i][n+1]=0;
	
	}
	for(j=0;j<n+2;j++){
		a[0][j]=0;
		a[m+1][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++){
			b=a[i+1][j]-a[i][j];
			c=a[i-1][j]-a[i][j];
			d=a[i][j+1]-a[i][j];
			e=a[i][j-1]-a[i][j];
			if(b<=0&&c<=0&&d<=0&&e<=0) {
				printf("%d %d\n",i-1,j-1);
			}
		}
	}
	return 0;
}
int main()
{
	int a[22][22];
	int m, n;
	memset(a, 0, sizeof(a));
	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 = 1; i <= m; i ++) {
		for(int 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][j+1] && a[i][j] >= a[i+1][j]) {
				printf("%d %d\n", i - 1, j - 1);
			}
		}
	}
	return 0;
}
int main()
{
    int a[40][40]={0};
    int b[40][40]={0};
    int m,n,m1,n1;
    scanf("%d %d",&m,&n);
    for (m1=1; m1<=m; m1++) {
        for (n1=1; n1<=n; n1++) {
            scanf("%d",&a[m1][n1]);
        }
    }
    
    for (m1=1; m1<=m; m1++) {
        for (n1=1; n1<=n; n1++) {
            if (a[m1][n1]>=a[m1-1][n1]&&a[m1][n1]>=a[m1][n1-1]&&a[m1][n1]>=a[m1][n1+1]&&a[m1][n1]>=a[m1+1][n1])
            {
                b[m1][n1]=1;
            }
        }
    }
    
    for (m1=1; m1<=m; m1++) {
        for (n1=1; n1<=n; n1++) {
            if (b[m1][n1]==1)
            {
                printf("%d %d\n",m1-1,n1-1);
            }
        }
    }
}
main()
{
   int m,n;
   scanf("%d %d",&m,&n);
   int key[20][20]={0},height[22][22]={0};
   for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
        scanf("%d",&height[i+1][j+1]);
   for(int i=0;i<m;i++)
     for(int j=0;j<n;j++)
     {
         if(height[i+1][j+1]>=height[i][j+1]
           &&height[i+1][j+1]>=height[i+2][j+1]
           &&height[i+1][j+1]>=height[i+1][j]
           &&height[i+1][j+1]>=height[i+1][j+2])  
           key[i][j]=1;  
     }
   for(int i=0;i<m;i++)
     for(int j=0;j<n;j++)
       if(key[i][j]==1)
         printf("%d %d\n",i,j);
   getchar();
   getchar();   
}
struct num{
	int row,col;
};
struct num b[10000];
int main()
{
	int m,n,i,j,a[25][25],c,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=0;i<=n+1;i++)
	{
		a[0][i]=0;
		a[m+1][i]=0;
	}
	for(j=0;j<=m+1;j++)
	{
		a[j][0]=0;
		a[j][n+1]=0;
	}
	c=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][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
		{
			b[c].row=i;
			b[c].col=j;
			c++;
		}
	}
	for(i=1;i<c;i++)
    for(j=0;j<c-i;j++)
    {
		if(b[j].row>b[j+1].row)
		{
			t=b[j].row;
			b[j].row=b[j+1].row;
			b[j+1].row=t;
			t=b[j].col;
			b[j].col=b[j+1].col;
			b[j+1].col=t;
		}
		if(b[j].row==b[j+1].row)
		{
			if(b[j].col>b[j+1].col)
			{
				t=b[j].col;
				b[j].col=b[j+1].col;
				b[j+1].col=t;
				t=b[j].row;
				b[j].row=b[j+1].row;
				b[j+1].row=t;
			}
		}
	}
	for(i=0;i<c;i++)
	printf("%d %d\n",b[i].row-1,b[i].col-1);
	return 0;
}
int main()
{
	int m,n,i,j;
	int hill[21][21]={0};
	cin>>m>>n;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>hill[i][j];
		}
	}
    


	for(j=1;j<n-1;j++)
		if(hill[0][j]>=hill[0][j-1]&&hill[0][j]>=hill[0][j+1]&&hill[0][j]>=hill[1][j])


	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i==0&&j==0&&hill[i][j]>=hill[i+1][j]&&hill[i][j]>=hill[i][j+1])
			    cout<<i<<" "<<j<<endl;
			else if(i==0&&j<n-1&&hill[i][j]>=hill[i+1][j]&&hill[i][j]>=hill[i][j+1]&&hill[i][j]>=hill[i][j-1])
				cout<<i<<" "<<j<<endl;
			else if(i==0&&j==n-1&&hill[i][j]>=hill[i+1][j]&&hill[i][j]>=hill[i][j-1])
				cout<<i<<" "<<j<<endl;
			else if(i>0&&i<m-1&&j==0&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i+1][j]&&hill[i][j]>=hill[i][j+1])
				cout<<i<<" "<<j<<endl;
			else if(i==m-1&&j==0&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i][j+1])
				cout<<i<<" "<<j<<endl;
			else if(i==m-1&&j<n-1&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i][j-1]&&hill[i][j]>=hill[i][j+1])
				cout<<i<<" "<<j<<endl;
			else if(i==m-1&&j==n-1&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i][j-1])
				cout<<i<<" "<<j<<endl;
			else if(i<m-1&&j==n-1&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i+1][j]&&hill[i][j]>=hill[i][j-1])
				cout<<i<<" "<<j<<endl;
			
			
			else if(i>0&&i<m-1&&j>0&&j<n-1&&hill[i][j]>=hill[i-1][j]&&hill[i][j]>=hill[i+1][j]&&hill[i][j]>=hill[i][j-1]&&hill[i][j]>=hill[i][j+1])
				cout<<i<<" "<<j<<endl;
		}
	}
	
	return 0;
}
void dump()
{
}
void seektop(int *point,int m,int n)
{
 int i,j=0;
 for(j=0;j<m;j++)
 {for(i=0;i<n;i++)
 {

  if(i==0&&j==0)
   point[i]>=point[i+1]&&point[i]>=point[i+20]?printf("%d %d\n",j,i):dump();
  else if(i==n-1&&j==0)
   point[i]>=point[i-1]&&point[i]>=point[i+20]?printf("%d %d\n",j,i):dump();
  else if(j==0)
   point[i]>=point[i+1]&&point[i]>=point[i+20]&&point[i]>=point[i-1]?printf("%d %d\n",j,i):dump();
  else if(i==0&&j!=m-1)
   point[i]>=point[i+1]&&point[i]>=point[i+20]&&point[i]>=point[i-20]?printf("%d %d\n",j,i):dump();
  else if(i==n-1&&j!=m-1)
   (point[i]>=point[i-1]&&point[i]>=point[i+20]&&point[i]>=point[i-20])?printf("%d %d\n",j,i):dump();
  else if(i==0&&j==m-1)
   (point[i]>=point[i+1]&&point[i]>=point[i-20])?printf("%d %d\n",j,i):dump();
  else if(i==n-1&&j==m-1)
   point[i]>=point[i-1]&&point[i]>=point[i-20]?printf("%d %d\n",j,i):dump();
  else if(j==m-1)
   point[i]>=point[i-1]&&point[i]>=point[i-20]&&point[i]>=point[i+1]?printf("%d %d\n",j,i):dump();
  else
   point[i]>=point[i-1]&&point[i]>=point[i+20]&&point[i]>=point[i-20]&&point[i]>=point[i+1]?printf("%d %d\n",j,i):dump();
 }
  point=point+20;//????????point=point+20*j?????????for??????????????????????
 }
}
void main()
{
 int m,n,i,j;
 scanf("%d%d",&m,&n);
 int height[20][20]={'\0'},*point=height[0];
 for(i=0;i<m;i++)
  for(j=0;j<n;j++)
   scanf("%d",&height[i][j]);
  seektop(point,m,n);
}
int main()
{
	int a[22][22];
	int m,n,i,j,c;
	scanf("%d%d",&m,&n);
	for(i=0;i<=m+1;i++)
	{
		a[i][0]=-1;
		a[i][n+1]=-1;
	}
	for(i=0;i<n+2;i++)
	{
		a[0][i]=-1;
		a[m+1][i]=-1;

	}
	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++)
		{
			c=a[i][j];
			if((c>=a[i][j+1])&&(c>=a[i][j-1])&&(c>=a[i+1][j])&&(c>=a[i-1][j]))
				printf("%d %d\n",i-1,j-1);
		}
		return 0;
}
int main()
{
	int m,n,i,j;
	int height[22][22],check[20][20];
	cin>>m>>n;
	for(i=0;i<22;i++)
	{
		for(j=0;j<22;j++)
		{
			height[i][j]=0;
		}
	}
	for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;j++)
		{
			cin>>height[i][j];
		}
	}
	for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;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])
			{
				check[i][j]=1;
			}
			else
			{
				check[i][j]=0;
			}
		}
	}
    for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;j++)
		{
			if(check[i][j]==1)
			{
				cout<<i-1<<" "<<j-1<<endl;
			}
			else
			{
				continue;
			}
		}
	}
	return 0;
}
int m,n;
int height[40][40];
double average[40][40];

int main(){
    int i,j;
    scanf("%d%d",&m,&n);
    memset(average,0,sizeof(average));
    
    for (i=0;i<m;i++){
        for (j=0;j<n;j++) scanf("%d",&height[i][j]);
    }
    
    for (i=0;i<m;i++){
        for (j=0;j<n;j++){
            double maxh;
            maxh = height[i][j];
            if (i>0 && height[i-1][j] > maxh) {
                maxh = height[i-1][j];
            }
            if (i<m-1 && height[i+1][j] > maxh) {
                maxh = height[i+1][j];
            }
            if (j>0 && height[i][j-1] > maxh) {
                maxh = height[i][j-1];
            }
            if (j<n-1 && height[i][j+1] > maxh) {
                maxh = height[i][j+1];
            }
            if (abs(maxh - (double)height[i][j]) < 0.000001) printf("%d %d\n",i,j);
        }
    }

    return 0;
}