semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
      int m,n,i,j,k;
      scanf("%d %d",&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;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])
                    printf("%d %d\n",i-1,j-1);
            }
      }
      getchar();
      getchar();
      getchar();
      getchar();
}
int main(int argc, char* argv[])
{
	int len,wid,i,j,a[20][20];
	scanf("%d%d",&len,&wid);
	for(i=0;i<len;i++)
	{for(j=0;j<wid;j++)
	{scanf("%d",&a[i][j]);}
	}
	for(i=0;i<len;i++)
	{for(j=0;j<wid;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==(wid-1)&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])
		    printf("%d %d\n",i,j);
		else if(i==(len-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(i==(len-1)&&j==(wid-1)&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])
		    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==(len-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(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(j==(wid-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(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 main()
{
    int m,n,i,j;
    int a[22][22],b[22][22];
    for(i=0;i<22;i++)
    {
        for(j=0;j<22;j++)
        {
            a[i][j]=-1;
            b[i][j]=0;
        }
    }
    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++)
        {
            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])
            {
                b[i][j]=1;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(b[i][j]==1)
            {
                printf("%d %d\n",i-1,j-1);
            }
        }
    }
    return 0;
}
int main(){
   int m,n,array[21][21],i,j;
   cin>>m>>n;
   for(i=1;i<=m;i++)
	   for(j=1;j<=n;j++)
		   cin>>array[i][j];
   if(array[1][1]>=array[1][2]&&array[1][1]>=array[2][1])
	   cout<<0<<' '<<0<<endl;
   for(i=2;i<n;i++)
	   if(array[1][i]>=array[1][i-1]&&array[1][i]>=array[1][i+1]&&array[1][i]>=array[2][i])
		   cout<<0<<' '<<i-1<<endl;
   if(array[1][n]>=array[1][n-1]&&array[1][n]>=array[2][n])
	   cout<<0<<' '<<n-1<<endl;
   for(i=2;i<m;i++)
   	   for(j=1;j<=n;j++)
   	   {
   		   if(j==1)
   			   if(array[i][1]>=array[i-1][1]&&array[i][1]>=array[i+1][1]&&array[i][1]>=array[i][2])
   				   cout<<i-1<<' '<<0<<endl;
   		   if(j==n)
   			   if(array[i][n]>=array[i-1][n]&&array[i][n]>=array[i+1][n]&&array[i][n]>=array[i][n-1])
   			   		cout<<i-1<<' '<<n-1<<endl;
   		   if(j!=1&&j!=n&&array[i][j]>=array[i][j+1]&&array[i][j]>=array[i][j-1]&&array[i][j]>=array[i+1][j]&&array[i][j]>=array[i-1][j])
   			   cout<<i-1<<' '<<j-1<<endl;

   	   }
   if(array[m][1]>=array[m][2]&&array[m][1]>=array[m-1][1])
	   cout<<m-1<<' '<<0<<endl;
   for(i=2;i<n;i++)
	   if(array[m][i]>=array[m][i-1]&&array[m][i]>=array[m][i+1]&&array[m][i]>=array[m-1][i])
		   cout<<m-1<<' '<<i-1<<endl;
   if(array[m][n]>=array[m][n-1]&&array[m][n]>=array[m-1][n])
	   cout<<m-1<<' '<<n-1<<endl;
   return 0;
}
int main(){
	int m,n;
	int shuzu[len][len];
	scanf("%d%d",&m,&n);
	for(int i=1;i<m+1;i++){
		for(int r=1;r<n+1;r++){
		scanf("%d",&shuzu[i][r]);
		}
	}

    for(int q=1;q<m+1;q++){

		 shuzu[q][0]=0;
	     shuzu[q][n+1]=0;
	}
	for(int e=1;e<n+1;e++){
			 shuzu[0][e]=0;
		     shuzu[m+1][e]=0;
	}
	
	for(int p=1;p<m+1;p++){
		for(int w=1;w<n+1;w++){
			if(shuzu[p][w]>=shuzu[p][w-1]&&shuzu[p][w]>=shuzu[p][w+1]){

				if(shuzu[p][w]>=shuzu[p+1][w]&&shuzu[p][w]>=shuzu[p-1][w]){
			   printf("%d %d\n",p-1,w-1);
				}
			}
		
		}
	
	}

	return 0;
}
int main()
{
	int n,m,i,j,A[25][25];
	cin>>n>>m;
	for(i=0;i<25;i++)
		for(j=0;j<25;j++)
			A[i][j]=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>A[i][j];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(A[i+1][j]-A[i][j]<=0&&A[i][j+1]-A[i][j]<=0&&A[i-1][j]-A[i][j]<=0&&A[i][j-1]-A[i][j]<=0)
				cout<<i-1<<' '<<j-1<<endl;
	return 0;
}
int main()
{
	int m,n,i,j,k,a[300][300]={0};
	scanf("%d %d",&m,&n);
	for(i=0;i<m;i++)
	{
		for(j=0;j<n-1;j++)
		{
			scanf("%d ",&a[i][j]);
		}
		scanf("%d",&a[i][j]);
	}
    for(i=0;i<m;i++)
	{
		for(j=0;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",i,j);
			    printf("\n");
			}
		}
	}
	return 0;
}
main()
{
       int m,n,i,j,c;
       scanf("%d %d",&m,&n);
       int a[100][100]={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);
          }
          }
          getchar();
          getchar();
}
int comp(int point, int up, int down, int left, int right)
{
      if ((point>=up)&&(point>=down)&&(point>=left)&&(point>=right)) return 1;
      else return 0;
}
int main()
{
    int a[22][22],j,k,m,n;
    scanf("%d%d",&m,&n);
    for(j=0;j<m+2; j++) {a[j][0]=-1; a[j][n+1]=-1;} // ?????
    for(k=1;k<n+1; k++) { a[0][k]=-1; a[m+1][k]=-1;} // ?????
    for(j=1;j<m+1; j++)
    {
                   for(k=1;k<n+1;++k)
                   {
                                     scanf("%d",&a[j][k]); // ???????
                   }
    }
    for(j=1;j<m+1; j++)
    {
                   for(k=1;k<n+1;++k)
                   {
                                     if(comp(a[j][k],a[j-1][k],a[j+1][k],a[j][k-1],a[j][k+1])==1)
                                     printf("%d %d\n",j-1,k-1);
                   }
    }
    getchar();
    getchar();
    getchar();
}
main()
{
    int a[25][25],m,n;
    memset(a,0,sizeof(a));
    scanf("%d",&m);
    scanf("%d",&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+1][j]
            &&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])
            printf("%d %d\n",i-1,j-1);
        }



}
int high(int h,int i,int j);
int away(int i,int j);
int num[30][30],m,n;
int main()
{
	int i,j;
	cin>>m>>n;
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			cin>>num[i][j];
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
		if(high(num[i][j],i,j)==1)
			cout<<i<<" "<<j<<endl;
	return 0;
}
int high(int h,int i,int j)
{
	int count1=0;
	if(num[i-1][j]<=h||away(i-1,j)==1)
		count1++;
	if(num[i+1][j]<=h||away(i+1,j)==1)
		count1++;
	if(num[i][j-1]<=h||away(i,j-1)==1)
		count1++;
	if(num[i][j+1]<=h||away(i,j+1)==1)
		count1++;
	if(count1==4)
		return 1;
	return 0;
}
int away(int i,int j)
{
	if(i<0||i>=m)
		return 1;
	if(j<0||j>=n)
		return 1;
	return 0;
}
void main()
{
	int n,m,a[25][25],i,j;
	char c;
	scanf("%d %d",&m,&n);
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			scanf("%d%c",&a[i][j],&c);
    for(j=0;j<=n+1;j++)
	{
		a[0][j]=-1;
		a[m+1][j]=-1;
	}
	for(i=0;i<=m+1;i++)
	{
		a[i][0]=-1;
		a[i][n+1]=-1;
	}
	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);
		}
	}
}
int main()
{
	int m,n,i,j;
	int a[20][20];
	scanf("%d %d\n",&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++)
	{

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

				else
				{
					for(j=0;j<n;j++)
					{
					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(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])
						 {
                          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);
					}
					}
				}


			}
		}

	
		

	return 0;
}
int main()
{
    int m,n;
    int a[25][25];
 
    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++)
    {
        a[i][0]=0;
        a[i][n+1]=0;
    }
    for(int i=1;i<=n;i++)
    {
        a[0][i]=0;
        a[m+1][i]=0;
    } 
    
    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 i,m,n,a[22][22],j,k,l,x;
    cin>>m>>n;
    for(i=0;i<=m+1;i++)
    {
        for(j=0;j<=n+1;j++)
        {
             a[i][j]=0;
        }
    }
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {cin>>x;a[i][j]=x;} 
    }
    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])
             {k=i-1;l=j-1;
             cout<<k<<" "<<l<<endl;}
        }
    } 
    return 0;
}
int main()
{
	int m,n,p=0,x[20000],y[20000],i,j,map[100][100];
	memset(map,0,sizeof(map));
	cin>>m>>n;
	for (i=1;i<=m;i++)
		for (j=1;j<=n;j++)
			cin>>map[i][j];
	for (i=1;i<=m;i++)
		for (j=1;j<=n;j++)
			if ((map[i][j]>=map[i-1][j])&&(map[i][j]>=map[i+1][j])&&(map[i][j]>=map[i][j-1])&&(map[i][j]>=map[i][j+1]))
			{p++;x[p]=i;y[p]=j;}
	for (i=1;i<=p;i++)
	{
		cout<<x[i]-1<<" "<<y[i]-1;
		if (i!=p) cout<<endl;
	}
	return 0;
}
int main()
{

	int hill[25][25]={0};
	int m=0, n=0;
	int average=0;

	cin>>m>>n;

	for(int i=1; i<=m; i++)
	{
		for(int j=1; j<=n; j++)
		{
			cin>>hill[i][j];
		
		}	
	}
		








	for(int i=1; i<=m; i++)
	{
		for(int j=1; j<=n; j++)
		{
			
				if(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-1<<" "<<j-1<<endl;
		
		
		}

	}


return 0;
}
int main()
{
	int m, n, i, j, temp;
	int a[100][100];
	cin >> m >> n;
	for(i = 1; i <= m; i++)
	{
		for(j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}
	for(i = 0; i <= n + 1; i++)
	{
		a[0][i] = 0;
		a[m + 1][i] = 0;
		a[i][0] = 0;
		a[n + 1][0] = 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])
			{
				cout << i - 1 << " " << j - 1 << endl;
			}
		}
	}
	return 0;
}
int main(){
int m,n,i,j,k,y;
scanf("%d%d",&m,&n);
int a[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(i=1;i<n-1;i++){
if(a[0][i]>=a[0][i-1]&&a[0][i]>=a[0][i+1]&&a[0][i]>=a[1][i]){
printf("0 %d\n",i);
}
}
if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1]){
printf("0 %d\n",n-1);
}
for(k=1;k<m-1;k++){
if(a[k][0]>=a[k-1][0]&&a[k][0]>=a[k][1]&&a[k][0]>=a[k+1][0]){
printf("%d 0\n",k);
}
for(i=1;i<n-1;i++){
if(a[k][i]>=a[k-1][i]&&a[k][i]>=a[k][i-1]&&a[k][i]>=a[k][i+1]&&a[k][i]>=a[k+1][i]){
printf("%d %d\n",k,i);
}
}
if(a[k][n-1]>=a[k-1][n-1]&&a[k][n-1]>=a[k][n-2]&&a[k][n-1]>=a[k+1][n-1]){
printf("%d %d\n",k,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(i=1;i<n-1;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]){
printf("%d %d\n",m-1,i);
}
}
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);
}
return 0;
}
int main(){
  int m,n,i,j;
  scanf("%d%d",&m,&n);
  int a[m+2][n+2];
  for(j=0;j<=n+1;j++){
     a[0][j]=0;
     a[m+1][j]=0;
     }
  for(i=1;i<=m;i++){
     a[i][0]=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-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);
          }
          }
          }
  scanf("%d",&n);
  return 0;
}
int a[25][25];
int main()
{
	int m,n,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++)
	  {
		if((i-1<0||a[i][j]>=a[i-1][j])&&
		(j-1<0||a[i][j]>=a[i][j-1])&&
		(i+1>=m||a[i][j]>=a[i+1][j])&&
		(j+1>=n||a[i][j]>=a[i][j+1]))
		 cout<<i<<' '<<j<<endl;
	  }
	return 0;
}
int main()
{
	int i,j,m,n,a[30][30]={0},I[3000]={0},J[3000]={0},p=0;
	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++)
		{
			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]))
			{
				I[p]=(i-1);
				J[p]=(j-1);
				p++;
			}
		}
	}
	for(i=0;i<p;i++)
	{
		printf("%d %d\n",I[i],J[i]);
	}
	return 0;
}
int main()
{
	int m,n ;
	int i,j ;
	cin>>m>>n ;
	int a[22][22] = {0} ;
	for(i=1 ; i<=m ; i++)
	{
		for(j=1; j<=n ; j++)
		{
			cin>>a[i][j] ;
		}
	}
	int b[400][2] ;
	int count = 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]))
			{
				b[count][0] = i-1 ;
				b[count][1] = j-1 ;
				count++ ;
			}
		}
	}
	for(i=0 ; i<count-1 ; i++)
	{
		for(j=0 ; j<count-i-1 ;i++)
		{
			if(b[j][1]>b[j+1][1])
			{
				int temp1,temp2 ;
				temp1 = b[j][0] ;
				b[j][0] = b[j+1][0] ;
				b[j+1][0] = temp1 ;
				temp2 = b[j][1] ;
				b[j][1] = b[j+1][1] ;
				b[j+1][1] = temp2 ;
			}
		}
	}
	for(i=0 ; i<count-1 ; i++)
	{
		for(j=0 ; j<count-1-i ;j++)
		{
			if(b[j][0]>b[j+1][0])
			{
				int temp3,temp4 ;
				temp3= b[j][0] ;
				b[j][0] = b[j+1][0] ;
				b[j+1][0] = temp3 ;
				temp4 = b[j][1] ;
				b[j][1] = b[j+1][1] ;
				b[j+1][1] = temp4 ;
			}
		}
	}
	for( i = 0 ; i<count ; i++)
	{
		cout<<b[i][0]<<" "<<b[i][1]<<endl ;
	}
	return 0 ;
}
int main(int argc, char* argv[])
{
	int m,n;
	scanf("%d%d",&m,&n);
	int a[20][20];
	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(i==0&&j==0&&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&&j<n-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);
			}
			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);
			}
			if(i>0&&i<m-1&&j==0&&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>0&&i<m-1&&j>0&&j<n-1&&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(i>0&&i<m-1&&j==n-1&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])
			{
				printf("%d %d\n",i,j);
			}
			if(i==m-1&&j==0&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])
			{
				printf("%d %d\n",i,j);
			}
			if(i==m-1&&j>0&&j<n-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);
			}
			if(i==m-1&&j==n-1&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
			{
				printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
}
int main()
{
    int m, n, i, j, a[30][30];
    for (i=0; i<30; i++)
        for (j=0; j<30; j++)
            a[i][j]=0;
    cin >> m >> n;
    for (i=1; i<=m; i++)
        for (j=1; j<=n; j++)
            cin  >> a[i][j];
    for (i=1; i<=m; i++)
        for (j=1; j<=n; j++)
        {
            if (a[i][j]>=a[i-1][j] && a[i][j]>=a[i+1][j] && a[i][j]>=a[i][j+1] && a[i][j]>=a[i][j-1])
                cout << i-1 << ' ' << j-1 <<'\n';
        }
    return 0;


}
int main()
{
    int m,n;
    cin>>m>>n;
    int a[30][30];
    for(int i=0;i<30;i++)
    for(int j=0;j<30;j++)
    {a[i][j]=-1;}
    for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
    {cin>>a[i][j];}
    if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0]) cout<<"0 0"<<endl;
    for(int i=1;i<n;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;
    }
    for(int i=1;i<m-1;i++)
    for(int j=0;j<n;j++)
    {
            if(j==0)
            {
                    if(a[i][0]>=a[i][1]&&a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0])
                    cout<<i<<" 0"<<endl;
                    }
                    else
                    {
                        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])
                        cout<<i<<" "<<j<<endl;
                        }
                        }
     if(a[m-1][0]>=a[m-1][1]&&a[m-1][0]>=a[m-2][0]&&a[m-1][0]>=a[m-2][1]) cout<<m-1<<" 0"<<endl;                   
    for(int i=1;i<n;i++)
    { if(a[m-1][i]>=a[m-1][i-1]&&a[m-1][i]>=a[m-2][i]&&a[m-1][i]>=a[m-1][i+1])
            cout<<m-1<<" "<<i<<endl;
    }

    return 0;
}
const int fx[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int w[30][30];
int chk(int x,int y){
	for(int i=0;i<4;i++)
		if(w[x][y]<w[x+fx[i][0]][y+fx[i][1]])return 0;
	return 1;
}
int main(){
	int m,n;
	cin>>m>>n;
	
	memset(w,-32768,sizeof(int));
	for(int i=1;i<=m;i++)for(int j=1;j<=n;j++)cin>>w[i][j];
	for(int i=1;i<=m;i++)for(int j=1;j<=n;j++)
		if(chk(i,j))cout<<i-1<<' '<<j-1<<endl;

	return 0;
}
int a[100][100];

int main()
{
    int m, n;
    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++) {
            if ((i > 0 && a[i][j] >= a[i-1][j]) || i == 0)
                if ((j > 0 && a[i][j] >= a[i][j-1]) || j == 0)
                    if (a[i][j] >= a[i+1][j] && a[i][j] >= a[i][j+1])
                        cout << i << " " << j << endl;
        }
    }
}
/*
 * 2.cpp
 *
 *  Created on: 2013-12-13
 *      Author: g199
 */

int main()
{
	int m,n;
	cin>>m>>n;
	int shan[m+2][n+2];
	for(int i=0; i<=m+1; i++)
		for(int j=0; j<=n+1; j++)
			shan[i][j]=0;
	for(int i=1; i<=m; i++)
		for(int j=1; j<=n; j++)
			cin>>shan[i][j];

	for(int i=1; i<=m; i++)
		for(int j=1; j<=n; j++)
		{
			if(shan[i][j]>=shan[i-1][j] &&
					shan[i][j]>=shan[i+1][j] &&
					shan[i][j]>=shan[i][j-1] &&
					shan[i][j]>=shan[i][j+1] )
				cout<<i-1<<" "<<j-1<<endl;
		}
	return 0;
}
int a[200][200];
int main(){

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

  return 0;
}
int main()
{
    int m,n,i,j;
    int a[22][22];
    int flag;
    int x,y;
    //freopen("5.in","r",stdin);
    //freopen("resullt.out","w",stdout);
    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++)
        {
            flag=1;
            
            x=i-1;
            y=j;
            if(flag==1&&x>=0)
            {
                if(a[i][j]<a[x][y])
                {
                    flag=0;
                }
            }
            x=i;
            y=j+1;
            if(flag==1&&y<n)
            {
                if(a[i][j]<a[x][y])
                {
                    flag=0;
                }
            }
            x=i;
            y=j-1;
            if(flag==1&&y>=0)
            {
                if(a[i][j]<a[x][y])
                {
                    flag=0;
                }
            }
            x=i+1;
            y=j;
            if(flag==1&&x<m)
            {
                if(a[i][j]<a[x][y])
                {
                    flag=0;
                }
            }
            if(flag)//flag==1
            {
                printf("%d %d\n",i,j);
            }
        }
    }
	
    return 0;
}
int main()
{
	int m,n,height[20][20],i,j,count = 0,a[401],b[401];
	cin >> m >> n;
    for(i = 0; i < m; i++)
		for(j = 0; j < n; j++)
		{
			cin >> height[i][j];
		}
	if(height[0][0] >= height[0][1] && height[0][0] >= height[1][0])
	{
		a[count] = 0;
		b[count] = 0;
		count++;
	}
	for(j = 1; j < n - 1; j++)
	{
		if(height[0][j] >= height[0][j -1]&& height[0][j] >= height[0][j+1] && height[0][j] >= height[1][j])
		{
			a[count] = 0;
			b[count] = j;
			count++;
		}
	}
	if(height[0][n - 1] >= height[0][n - 2] && height[0][n - 1] >= height[1][n - 1])
	{
			a[count] = 0;
			b[count] = n - 1;
			count++;
	}
	for(i = 1; i < m - 1; i++)
	{
		if(height[i][0] >= height[i + 1][0] && height[i][0] >= height[i][1] && height[i][0] >= height[i - 1][0])
		{
			a[count] = i; 
			b[count] = 0;
			count++;
		}
		for(j = 1; j < n - 1;j++)
		{
			if(height[i][j] >= height[i - 1][j] && height[i][j] >= height[i][j- 1] && height[i][j] >= height[i][j +1] && height[i][j] >= height[i +1][j])
				
			{
			a[count] = i; 
		b[count] = j;
			count++;
			}
		}
	   if(height[i][n - 1] >= height[i][n - 2] && height[i][n - 1] >= height[i + 1][n - 1] && height[i][n - 1] >= height[i - 1][n - 1])
		{
			a[count] = i; 
			b[count] = n - 1;
			count++;
	   }
	   }
     if(height[m - 1][0] >= height[m -1][1] && height[m -1][0] >= height[m - 2][0])
		{
			a[count] = m -1;
			b[count] = 0;
			count++;
		}
		for(j = 1; j < n - 1; j++)
		{
			if(height[m -1][j] >= height[m -1][j -1]&& height[m -1][j] >= height[m -1][j+1] && height[m -1][j] >= height[m -2][j])
			{
				a[count] = m -1;
				b[count] = j;
				count++;
			}
		}
		if(height[m -1][n - 1] >= height[m -1][n - 2] && height[m -1][n - 1] >= height[m -2][n - 1])
		{
				a[count] = m -1;
				b[count] = n - 1;
				count++;
		}
		for(i = 0; i < count; i++)
		    cout << a[i] << " " << b[i] << endl;
	return 0;
}
int main(){
	int a,b,c,d,e,m,n,i,j,k;
	int q[22][22];
	scanf("%d%d",&m,&n);
	for(i=1;i<m;i++){
		for(j=1;j<n+1;j++){
			scanf("%d",&q[i][j]);
		}
		scanf("\n");
	}
	for(i=m,j=1;j<n+1;j++){
		scanf("%d",&q[i][j]);
	}
	for(i=0;i<m+2;i++){
		for(j=0;j<n+2;j++){
			if(i==0||j==0||i==m+1||j==n+1){
				q[i][j]=0;
			}
		}
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(q[i][j]>=q[i+1][j]&&q[i][j]>=q[i][j+1]&&q[i][j]>=q[i-1][j]&&q[i][j]>=q[i][j-1]){
				d=i-1;
				e=j-1;
				printf("%d %d\n",d,e);
			}
		}
	}
	return 0;
}