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

}
int area[100][100];
int main(){
    int m;
    int n;
    int i;
    int j;
    scanf("%d",&m);
    scanf("%d",&n); 
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
          scanf("%d",&area[i][j]);
    }}
     for(i=0;i<m;i++){
        for(j=0;j<n;j++){
           if((area[i][j]>=area[i-1][j])&&(area[i][j]>=area[i+1][j])&&(area[i][j]>=area[i][j-1])&&(area[i][j]>=area[i][j+1])){
               printf("%d %d\n",i,j);         }}
    }
    return 0;
}
struct p
{
	int m;
	int n;
}a[20];
int main()
{
	int m, n, i, j, num[22][22], count = 0, l, k;
	cin >> m >> n;
	for(l = 0; l < 22; l++)
		for(k = 0; k < 22; k++)
			num[l][k] = 0;
	for(i = 1; i <= m; i++)
		for(j = 1; j <= n; j++)
			cin >> num[i][j];
	for(i = 1; i <= m; i++)
		for(j = 1; j <= n; j++)
		{
			if(num[i][j] >= num[i - 1][j] && num[i][j] >= num[i][j - 1] && num[i][j] >= num[i][j + 1] && num[i][j] >= num[i + 1][j])
			{
				a[count].m = i - 1;
				a[count].n = j - 1;
				count++;
			}
		}
	for(i = 0; i < count; i++)
	{
		cout << a[i].m << " " << a[i].n << endl;
	}
	return 0;
}
int main()
{
	int a,e,m,n,i,j;
	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+1;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j-1]){
				a=i-1;
				e=j-1;
				printf("%d %d\n",a,e);
			}
		}
	}
	return 0;
}
int main()
{
	int a[21][21],i,j,m,n;
	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 && a[i][j]>=a[i+1][j] && a[i][j]>=a[i][j+1] )
					cout<<i<<" "<<j<<endl;
				else if(j==n-1 && a[i][j]>=a[i+1][j] && a[i][j]>=a[i][j-1] )
					cout<<i<<" "<<j<<endl;
				else if(a[i][j]>=a[i][j-1] && a[i][j]>=a[i][j+1] && a[i][j]>=a[i+1][j])
					cout<<i<<" "<<j<<endl;
			}
			else if(i==m-1){
				if(j==0 && a[i][j]>=a[i-1][j] && a[i][j]>=a[i][j+1] )
					cout<<i<<" "<<j<<endl;
				else if(j==n-1 && a[i][j]>=a[i-1][j] && a[i][j]>=a[i][j-1] )
					cout<<i<<" "<<j<<endl;
				else if(a[i][j]>=a[i][j-1] && a[i][j]>=a[i][j+1] && a[i][j]>=a[i-1][j])
					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 main(){
    int N=100;
    int a[N][N],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 dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main()
{
	int m, n;
	cin >> m >> n;
	double mount[22][22];
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
			cin >> mount[i][j];
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
		{
			int num = 0;
			double sum = 0;
			int k;
			for (k = 0; k < 4; k++)
			{
				int tempi = i + dx[k];
				int tempj = j + dy[k];
				if (tempi >= 0 && tempi < m && tempj >= 0 && tempj < n)
				{
					if(mount[i][j] < mount[tempi][tempj])
						break;
				}
			}
			if (k == 4)
				cout << i << " " << j << endl;
		}
	return 0;
}
int main()
{
	int m,n,h[20][20];
	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(!(i - 1 >= 0 && h[i][j] < h[i-1][j])+ !(i + 1 < m && h[i][j] < h[i+1][j])+!(j - 1 >= 0 && h[i][j] < h[i][j-1])
				+!(j+ 1 <n && h[i][j] < h[i][j+1])==4)
				cout <<i <<' ' <<j <<endl;
		}
		return 0;
}
int f(int i,int j,int m,int n,int a[100][100]); 
int main()
{
    int m,n,i,j,a[100][100];
    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(f(i,j,m,n,a)==1)
         printf("%d %d\n",i,j);
       }
}                        
int f(int i,int j,int m,int n,int a[100][100]) 
{
    int i1,j1,k,test=1;
    int d[4][2]={-1,0,1,0,0,-1,0,1};
    for( k=0;k<4;k++)
       {
           i1=i+d[k][0];
           j1=j+d[k][1];
           if(i1>=0 && i1<m &&j1>=0 &&j1<n)
           {
             if(a[i][j]<a[i1][j1])
             {
               test=0;
               break;
             }
           }
       }
       if(test==0)
       return 0;
       else 
       return 1; 
}
int main(){
	int n,s[A][A],k=0,e,d,i,a,m;
	scanf("%d %d",&m,&n);
	for(i=0;i<A;i++){
		for(a=0;a<A;a++){
			s[i][a]=0;
		}
	}
	for(e=1;e<m+1;e++){
		for(d=1;d<n+1;d++){
			scanf("%d",&s[e][d]);
		}
	}
	for(e=1;e<m+1;e++){
		for(d=1;d<n+1;d++){
			if(s[e][d]>=s[e+1][d]&&s[e][d]>=s[e-1][d]&&s[e][d]>=s[e][d+1]&&s[e][d]>=s[e][d-1]){
			printf("%d %d\n",e-1,d-1);
			}
		}
	}
	return 0;
}
int main()
{
	int a[22][22]={0};
	int m,n,i,j;
	scanf("%d%d",&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,a[30][30]={0},x[100]={0},y[100]={0},count=0,i=0,j=0;
	cin>>m>>n;
	for(i=2;i<=m+1;i++)
		for(j=2;j<=n+1;j++)
			cin>>a[i][j];
	for(i=2;i<=m+1;i++)
	{
		for(j=2;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])
			{
				count++;
				x[count]=i;
				y[count]=j;
			}
		}
	}
	for(i=1;i<=count-1;i++)
		cout<<x[i]-2<<" "<<y[i]-2<<endl;
	cout<<x[count]-2<<" "<<y[count]-2;
	return 0;
}
int main ()
{
	int m, n, i, j;
	int a[100][100];
	cin >> m >> n;
	for (i = 0; i < m;i++)
		for ( j = 0; j <n;j++)
			cin >> a[i][j];
	for (i = 0; i < m;i++)
	{
		for ( j = 0; j < n;j++)
		{
			if (j == n-1)
			{
				if(a[i][j] >= a[i][j-1])
				{
					if (i ==0)
					{
						if (a[i][j]>= a[i+1][j])
							cout << i << " " << j <<endl;
					}
					else if (i == m-1)
					{
						if ( 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]))
							cout << i << " " << j <<endl;
					}
				}
			}
			else if ( j == 0)
			{
				if(a[i][j] >= a[i][j+1])
				{
					if (i ==0)
					{
						if (a[i][j]>= a[i+1][j])
							cout << i << " " << j <<endl;
					}
					else if (i == m-1)
					{
						if ( 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]))
							cout << i << " " << j <<endl;
					}
				}
			}
			else
			{
				if ((a[i][j] >= a[i][j+1]) && (a[i][j] >= a[i][j-1]))
				{
					if ( i == 0)
					{
						if (a[i][j] >=a[i+1][j])
							cout << i << " " << j <<endl;
					}
					else if (i == m-1)
					{
						if ( 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]))
							cout << i << " " << j <<endl;	
					}
				}
			}
		}
	}
	return 0;
}
void main()
{
	int m,n,j,i,a[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])
					printf("%d %d\n",i,j);
			}
			else
				if(i==0&&j==n-1)
				{
				    if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
				    	printf("%d %d\n",i,j);
				}
				else
			    	if(i==m-1&&j==0)
					{
				        if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])
				        	printf("%d %d\n",i,j);
					}
					else
			        	if(i==m-1&&j==n-1)
						{
			        	    if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
				             	printf("%d %d\n",i,j);
						}
						else
							if(i==0)
							{
			             	    if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
									printf("%d %d\n",i,j);
							}
							else
							if(i==m-1)
							{
			             	    if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])
									printf("%d %d\n",i,j);
							}
							else
							if(j==0)
							{
			             	    if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])
									printf("%d %d\n",i,j);
							}
							else
							if(j==n-1)
							{
			             	    if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])
									printf("%d %d\n",i,j);
							}
							else
							{
								if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])
									printf("%d %d\n",i,j);
							}
}
int main()
{
 	int a[25][25], m, n, k;
 	int dx[4] = { 0, 0, 1, -1 }, dy[4] = { 1, -1, 0, 0 };
 	cin >> m >> n;
 	
 	for (  int i = 0; i < m; i++ )
 	{
  	 	for (  int j = 0; j < n; j++ )
  	 		cin >> a[i][j];
 	}
 	
 	for ( int i = 0; i < m; i++ )
 	{
  	 	for ( int j = 0; j < n; j++ )
  	 	{
  	  	 	for ( k = 0; k < 4; k++ )
  	  	 	{
  	  		 	if ( i + dx[k] >= 0 && i + dx[k] < m && j + dy[k] >= 0 && j + dy[k] < n )
  	  		 	{
   	   	 		    if ( a[i][j] < a[i+dx[k]][j+dy[k]] )
   	   	 		       break;
		   		}
			}
			if ( k == 4 )
			   cout << i << " " << j << endl;
	 	}
  	}
  	return 0;
}
int main(int argc, char* argv[])
{
	int (*p)[22],i,j,a,b;
	p=(int(*)[22])calloc(22,22*sizeof(int));
	scanf("%d %d",&a,&b);
	memset(p,0,sizeof(p));
	for(i=1;i<a+1;i++)
		for(j=1;j<b+1;j++)
			scanf("%d",*(p+i)+j);
	for(i=1;i<=a;i++)
		for(j=1;j<=b;j++)
		{
			if(*(*(p+i)+j)>=*(*(p+i-1)+j)&&*(*(p+i)+j)>=*(*(p+i+1)+j)&&*(*(p+i)+j)>=*(*(p+i)+j+1)&&*(*(p+i)+j)>=*(*(p+i)+j-1))
				printf("%d %d\n",i-1,j-1);
		}
}
int main(){
    int i,j;
    int n,m;
	scanf("%d %d",&m,&n);
	int sz[23][23];
	for(i=0;i<=m+1;i++){
		for(j=0;j<=n+1;j++){
			sz[i][j]=0;
		}
	}
    for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&(sz[i][j]));
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if((sz[i][j]>=sz[i-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 , order = 1;
	int i , j ;
	cin >> m >> n ;
	int a[25][25] ,peakx[444],peaky[444];
	for ( i = 1 ; i <= m ; i ++ ) {
		for ( j =1 ; j <= n ; j ++ ) {
			cin >> a[i][j] ;
		}
	}
	if ( ( a[1][1] >= a[1][2]) && ( a[1][1] >= a[2][1] ) ) {
		peakx[order] = 1 ;
		peaky[order] = 1 ;
		order ++ ;
	}
	for ( i = 2 ; i < n ; i ++ ) {
		if ( ( a[1][i] >= a[1][i+1]) && ( a[1][i] >= a[1][i-1] ) && ( a[1][i] >= a[2][i] ) ) {
			peakx[order] = 1 ;
			peaky[order] = i ;
			order ++ ;
		}
	}
	if ( ( a[1][n] >= a[1][n-1]) && ( a[1][n] >= a[2][n] ) ) {
		peakx[order] = 1 ;
		peaky[order] = n ;
		order ++ ;
	}
	for ( i = 2 ; i < m ; i ++ ) {
		if ( ( a[i][1] >= a[i][2]) && ( a[i][1] >= a[i-1][1] ) && ( a[i][1] >= a[i+1][1] ) ) {
			peakx[order] = i ;
			peaky[order] = 1 ;
			order ++ ;
		}
		for ( j = 2 ; 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] ) ) {
			peakx[order] = i ;
			peaky[order] = j ;
			order ++ ;
			}
		}
		if ( ( a[i][n] >= a[i][n-1]) && ( a[i][n] >= a[i-1][n] ) && ( a[i][n] >= a[i+1][n] ) ) {
			peakx[order] = i ;
			peaky[order] = n ;
			order ++ ;
		}
	}
	if ( ( a[m][1] >= a[m][2]) && ( a[m][1] >= a[m-1][1] ) ) {
		peakx[order] = m ;
		peaky[order] = 1 ;
		order ++ ;
	}
	for ( i = 2 ; i < n ; i ++ ) {
		if ( ( a[m][i] >= a[m][i+1]) && ( a[m][i] >= a[m][i-1] ) && ( a[m][i] >= a[m-1][i] ) ) {
			peakx[order] = m ;
			peaky[order] = i ;
			order ++ ;
		}
	}
	if ( ( a[m][n] >= a[m][n-1]) && ( a[m][n] >= a[m-1][n] ) ) {
		peakx[order] = m ;
		peaky[order] = n ;
		order ++ ;
	}
	for ( i = 1 ; i < order ; i ++ ) {
		cout << peakx[i] -1 << " " << peaky[i] - 1  ;
		if ( i != ( order-1 ) )
			cout << endl ;
	}
	return 0 ;
}
int main(){
	int k,i,j,m,n,x[1000],y[1000];
	scanf("%d%d", &m, &n);
	int a[A+2][A+2]={0};
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			scanf("%d", &a[i][j]);
		}
	}
	k=0;
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(a[i][j] >= a[i-1][j] && a[i][j] >= a[i+1][j] &&
				a[i][j] >= a[i][j-1] && a[i][j] >= a[i][j+1]){
				x[k]=i-1;
				y[k]=j-1;
				k++;
			}
		}
	}
	for(i=0;i<k;i++){
		printf("%d %d\n", x[i], y[i]);
	}
	return 0;
}
int main(){
	int a[MAX+2][MAX+2]={0};
	int m, n, i, j;
	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++){
			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;
}
int main(){
	int a[25][25],m,n,p,q,s=0,l,f;
	scanf("%d %d",&m,&n);
	for(p=1;p<m+1;p++){
		for(q=1;q<n+1;q++){
			scanf("%d",&a[p][q]);
		}
	}
	for(l=0;l<n+2;l++){
		a[0][l]=0;
		a[m+1][l]=0;
	}
	for(f=0;f<m+2;f++){
		a[f][0]=0;
		a[f][n+1]=0;
	}
	for(p=1;p<m+1;p++){
		for(q=1;q<n+1;q++){
			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]){
				continue;
			}else{
				printf("%d %d\n",p-1,q-1);
			}
		}
	}
	return 0;
}
int main()
{
 int m,n,a[100][100];
 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]);                
  }                
 }
 
 if(a[0][0]>a[0][1]&&a[0][0]>a[1][0])
  printf("0 0\n");
 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])
   printf("0 %d\n",j);                   
 }
 if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1]) 
  printf("0 %d\n",n-1);
 
 
 
 for(i=1;i<m-1;i++)
 {
  if(a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0]&&a[i][0]>=a[i][1])
   printf("%d 0\n",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,j);                
  }
  if(a[i][n-1]>=a[i-1][n-1]&&a[i][n-1]>=a[i+1][n-1]&&a[i][n-1]>=a[i][n-2])
    printf("%d %d\n",i,n-1);                  
 } 

 
 
 
 if(a[m-1][0]>=a[m-1][1]&&a[m-1][0]>=a[m-2][0])
   printf("%d 0\n",m-1);
 for(j=1;j<n-1;j++)
 {
  if(a[m-1][j]>=a[m-1][j+1]&&a[m-1][j]>=a[m-1][j-1]&&a[m-1][j]>=a[m-2][j])
   printf("%d %d\n",m-1,j);                   
 }  
 if(a[m-1][n-1]>=a[m-1][n-2]&&a[m-1][n-1]>=a[m-2][n-1]) 
  printf("%d %d\n",m-1,n-1); 
  
 getchar();
 getchar();
 return 0; 
  
  
  
    
}
int main()
{
	int m,n,i,j;
	scanf("%d %d\n",&m,&n);
	int sz[22][22];
	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+1;j++){
			scanf("%d",&sz[i][j]);}}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i-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 sz[max+2][max+2]={0};
	int m,n,i,j;
	scanf("%d%d",&m,&n);
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(sz[i][j]>=sz[i][j+1]  && sz[i][j]>=sz[i][j-1] && sz[i][j]>=sz[i+1][j] && sz[i][j]>=sz[i-1][j])
			{printf("%d %d\n",i-1,j-1);}
		}
	}
return 0;
}
int a[21][21];
int main()
{
    int m,n,i,j,f;
    int s=0;
    scanf("%d%d",&m,&n);
    f=0;
    for(i=0;i<=m+1;i++)
    {
        for(j=0;j<=n+1;j++)
        {
            if(i==0 && i==n+1 && j==0 && j==m+1)
            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][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;
	int 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&&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;
			}
			if(i==0&&j!=0&&j!=n-1)
			{
				if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])
					cout<<i<<' '<<j<<endl;
			}
			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(j==0&&i!=0&&i!=m-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(j==n-1&&i!=0&&i!=m-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==0&&j==0)
			{
				if(a[i][j]>=a[i+1][j]&&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(j==0&&i==m-1)
			{
				if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])
					cout<<i<<' '<<j<<endl;
			}
			if(j==n-1&&i==m-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;
    scanf("%d%d",&m,&n);
    int sz[1000][1000];
    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((i!=1&&j!=1&&i!=m&&j!=n&&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])||
            (i==1&&j==1&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1])||
            (i==m&&j==n&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i-1][j])||
            (i==1&&j!=1&&j!=n&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i+1][j])||
            (i==m&&j!=1&&j!=n&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i-1][j])||
            (j==1&&i!=1&&i!=m&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j+1])||
            (j==n&&i!=1&&i!=m&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j-1])||
            (i==1&&j==n&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i+1][j])||
            (i==m&&j==1&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j+1])){
                printf("%d %d\n",i-1,j-1);
            }
}
}
return 0;
}
int main(){
	int sz[21][21];
	int i,j;
	int x;
	int m,n;
	int S=0,C=0;
	scanf("%d %d",&m,&n);
	for(i=0;i<=m+1;i++){
		for(j=0;j<=n+1;j++){
			sz[i][j]=0;
		}
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			scanf("%d",&x);
			sz[i][j]=x;
		}
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+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 = 0, n = 0;                   //????????
	int a[21][21] = {0};                //????
	int i = 0, j = 0;
	cin >> m >> n;
	for(i = 0; i < m ; i ++)
		for(j = 0 ; j < n ; j ++)
			cin >> a[i][j];               //????
	for(i = 0; i < m; i ++)
		for(j = 0 ; j < n; j ++)
		{
			int flag = 1;                 //???????????????
			if((i - 1 >= 0) && (a[i - 1][j] > a[i][j]))
				flag = 0;
			if((j - 1 >= 0) && (a[i][j - 1] > a[i][j]))
				flag = 0;
			if((i + 1 < m) && (a[i + 1][j] > a[i][j]))
				flag = 0;
			if((j + 1 < n) && (a[i][j + 1] > a[i][j]))
				flag = 0;
			if(flag == 1)
				cout << i << ' ' << j << endl;//???????
		}
	return 0;
}
int main ()
{int m,n;
scanf("%d%d",&m,&n);
int mj[m][n];
for (int i1=0;i1<m;i1++)
{
   for (int j1=0;j1<n;j1++)
   {
    scanf("%d",&mj[i1][j1]);
   }
} 
for (int i2=0;i2<m;i2++)
{
   for (int j2=0;j2<n;j2++)
   {
    if (i2==0||i2==m-1||j2==0||j2==n-1)
    {
     if(i2==0&&j2==0&&mj[i2][j2]>=mj[i2+1][j2]&&mj[i2][j2]>=mj[i2][j2+1]){printf("%d %d\n",i2,j2);}
     if(i2==0&&j2==n-1&&mj[i2][j2]>=mj[i2+1][j2]&&mj[i2][j2]>=mj[i2][j2-1]){printf("%d %d\n",i2,j2);}
     if(i2==m-1&&j2==0&&mj[i2][j2]>=mj[i2-1][j2]&&mj[i2][j2]>=mj[i2][j2+1]){printf("%d %d\n",i2,j2);}
     if(i2==m-1&&j2==n-1&&mj[i2][j2]>=mj[i2-1][j2]&&mj[i2][j2]>=mj[i2][j2-1]){printf("%d %d\n",i2,j2);}
     if(i2==0&&j2!=0&&j2!=n-1&&mj[i2][j2]>=mj[i2+1][j2]&&mj[i2][j2]>=mj[i2][j2+1]&&mj[i2][j2]>=mj[i2][j2-1]){printf("%d %d\n",i2,j2);}
     if(i2==m-1&&j2!=0&&j2!=n-1&&mj[i2][j2]>=mj[i2-1][j2]&&mj[i2][j2]>=mj[i2][j2+1]&&mj[i2][j2]>=mj[i2][j2-1]){printf("%d %d\n",i2,j2);}
     if(j2==0&&i2!=0&&i2!=m-1&&mj[i2][j2]>=mj[i2+1][j2]&&mj[i2][j2]>=mj[i2][j2+1]&&mj[i2][j2]>=mj[i2-1][j2]){printf("%d %d\n",i2,j2);}
     if(j2==n-1&&i2!=0&&i2!=m-1&&mj[i2][j2]>=mj[i2+1][j2]&&mj[i2][j2]>=mj[i2][j2-1]&&mj[i2][j2]>=mj[i2-1][j2]){printf("%d %d\n",i2,j2);}
    }
    else{
    if (mj[i2][j2]>=mj[i2-1][j2]&&mj[i2][j2]>=mj[i2+1][j2]&&mj[i2][j2]>=mj[i2][j2-1]&&mj[i2][j2]>=mj[i2][j2+1]){printf("%d %d\n",i2,j2);} 
     }
   }
}
return 0;
}
int main(){
	int m,n,i,j;
	cin>>m>>n;
	int bo[m][n];
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			cin>>bo[i][j];
	if(bo[0][0]>=bo[0][1]&&bo[0][0]>=bo[1][0])
		cout<<0<<" "<<0<<endl;
	for(j=1;j<n-1;j++)
		if(bo[0][j]>=bo[0][j-1]&&bo[0][j]>=bo[0][j+1]&&bo[0][j]>=bo[1][j])
			cout<<0<<" "<<j<<endl;
	if(bo[0][n-1]>=bo[0][n-2]&&bo[0][n-1]>=bo[1][n-1])
			cout<<0<<" "<<n-1<<endl;
	for(i=1;i<m-1;i++){
		if(bo[i][0]>=bo[i-1][0]&&bo[i][0]>=bo[i+1][0]&&bo[i][0]>=bo[i][1])
			cout<<i<<" "<<0<<endl;
		for(j=1;j<n-1;j++)
			if(bo[i][j]>=bo[i-1][j]&&bo[i][j]>=bo[i+1][j]&&bo[i][j]>=bo[i][j-1]&&bo[i][j]>=bo[i][j+1])
				cout<<i<<" "<<j<<endl;
		if(bo[i][n-1]>=bo[i-1][n-1]&&bo[i][n-1]>=bo[i+1][n-1]&&bo[i][n-1]>=bo[i][n-2])
				cout<<i<<" "<<n-1<<endl;
	}
	if(bo[m-1][0]>=bo[m-1][1]&&bo[m-1][0]>=bo[m-2][0])
		cout<<m-1<<" "<<0<<endl;
	for(j=1;j<n-1;j++)
		if(bo[m-1][j]>=bo[m-1][j-1]&&bo[m-1][j]>=bo[m-1][j+1]&&bo[m-1][j]>=bo[m-2][j])
			cout<<m-1<<" "<<j<<endl;
	if(bo[m-1][n-1]>=bo[m-1][n-2]&&bo[m-1][n-1]>=bo[m-2][n-1])
		cout<<m-1<<" "<<n-1<<endl;
	return 0;
}
int main()
{
    int m,n;
    int hill[20][20];
    int i,j;
    scanf("%d %d",&m,&n);
    for(i=0;i<m;i++)
       for(j=0;j<n;j++)
          scanf("%d",hill[i]+j);
    
    for(i=0;i<m;i++)
       for(j=0;j<n;j++)
          if(i==0||hill[i][j]>=hill[i-1][j])
             if(i==m-1||hill[i][j]>=hill[i+1][j])
                if(j==0||hill[i][j]>=hill[i][j-1])
                   if(j==n-1||hill[i][j]>=hill[i][j+1])
                      printf("%d %d\n",i,j);
    return 1;
}
main()
{
    int a[21][21];
    int i,j,k,m,n;
    for(i=0;i<21;i++)
     for(j=0;j<21;j++)
      a[i][j]=0;
    scanf("%d %d",&m,&n);
    for(i=1;i<m+1;i++)
     for(j=1;j<n+1;j++)
      scanf("%d",&a[i][j]);
    for(i=1;i<m+1;i++)
     {
         for(j=1;j<n+1;j++)
          {
              if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
                printf("%d %d\n",i-1,j-1);
          }
     }



}