semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void find(int s[22][22],int x,int y,int m,int n)
{
	if(x==0&&y==0){
		if((s[x][y]>=s[x+1][y])&&(s[x][y]>=s[x][y+1]))
			cout<<x<<' '<<y<<endl;
		return;
	}
	if(x==m&&y==n){
		if((s[x][y]>=s[x-1][y])&&(s[x][y]>=s[x][y-1]))
			cout<<x<<' '<<y<<endl;
		return;
	}
	if(x==m&&y==0){
		if((s[x][y]>=s[x][y+1])&&(s[x][y]>=s[x-1][y]))
			cout<<x<<' '<<y<<endl;
		return;
	}
	if(x==0&&y==n){
		if((s[x][y]>=s[x+1][y])&&(s[x][y]>=s[x][y-1]))
			cout<<x<<' '<<y<<endl;
		return;
	}
	if(x==0){
		if((s[x][y]>=s[x][y+1])&&(s[x][y]>=s[x][y-1])&&(s[x][y]>=s[x+1][y]))
			cout<<x<<' '<<y<<endl;
		return;
	}
	if(y==0){
		if((s[x][y]>=s[x][y+1])&&(s[x][y]>=s[x+1][y])&&(s[x][y]>=s[x-1][y]))
					cout<<x<<' '<<y<<endl;
				return;
	}
	if(x==m){
		if((s[x][y]>=s[x][y+1])&&(s[x][y]>=s[x][y-1])&&(s[x][y]>=s[x-1][y]))
					cout<<x<<' '<<y<<endl;
				return;
	}
	if(y==n){
		if((s[x][y]>=s[x][y-1])&&(s[x][y]>=s[x+1][y])&&(s[x][y]>=s[x-1][y]))
							cout<<x<<' '<<y<<endl;
						return;
	}
	if((s[x][y]>=s[x-1][y])&&(s[x][y]>=s[x+1][y])&&(s[x][y]>=s[x][y-1])&&(s[x][y]>=s[x][y+1]))
		cout<<x<<' '<<y<<endl;
}
int main(){
	int m,n,i,j;
	cin>>m>>n;
	int a[22][22];
	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++)
			find(a,i,j,m-1,n-1);
	return 0;
}
int main()
{  int height[20][20]={0},m,n;
   cin>>m>>n;
   int i,j;
   for(i=0;i<m;i++)
   {
	   for(j=0;j<n;j++) cin>>height[i][j];
   }
   int judge,piece;
   for(i=0;i<m;i++)
   {
	   for(j=0;j<n;j++)
	   {
		   piece=0;
		   judge=0;
		   if(i>=1) { judge+=(height[i][j]>=height[i-1][j]);piece++;}
		   if(i<m-1) { judge+=(height[i][j]>=height[i+1][j]);piece++;}
		   if(j>=1) { judge+=(height[i][j]>=height[i][j-1]); piece++;}
		   if(j<n-1){ judge+=(height[i][j]>=height[i][j+1]);piece++;}
		   if(judge==piece)
		   {
			   cout<<i<<" "<<j<<endl;
		   }

	   }
   }
   cin.get();
   cin.get();
   cin.get();


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

 }
  }
   else if(c==m-1&&d!=n-1){
     if(sz[c][d]>=sz[c][d-1]&&sz[c][d]>=sz[c-1][d]&&sz[c][d]>=sz[c][d+1]){
      printf("%d %d\n",c,d);                                               
     }     
   }
 else if(c==m-1&&d==n-1){
     if(sz[c][d]>=sz[c][d-1]&&sz[c][d]>=sz[c-1][d]){
      printf("%d %d\n",c,d);                                               
     }     
   }
 }
  }
  return 0;       
}
int main()
{
	int m=0,n=0,i=0,j=0;
	cin>>m>>n;
	int a[21][21],sign[21][21]={0};
	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 k=0,sum=0;
			if(i-1>=0)
			{
				k++;
				if(a[i][j]>=a[i-1][j])
					sum++;
			}
			if(i+1<m)
			{
				k++;
				if(a[i][j]>=a[i+1][j])
					sum++;
				
			}
			if(j-1>=0)
			{
				k++;
				if(a[i][j]>=a[i][j-1])
					sum++;
				
			}
			if(j+1<n)
			{
				k++;
				if(a[i][j]>=a[i][j+1])
					sum++;
				
			}
			
			if(sum==k)
				sign[i][j]=1;
			
		}
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
		{
			if(sign[i][j]==1)
				cout<<i<<" "<<j<<endl;
		}
		return 0;
}
int main()
{
	int m,n;
	int a[20][20];
	int i,j;
	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++){
		for(j=0;j<n;j++){
            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==0&&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==0&&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==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-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(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][j-1]){
                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);
			}
		}
	}
	return 0;
}
void main()
{
	int m,n;
	int h[20][20];
	int i,j;
	int sign;

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

	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			sign=1;
			if(i>0&&h[i][j]<h[i-1][j])
				sign=0;
			else if(i<m-1&&h[i][j]<h[i+1][j])
				sign=0;
			else if(j>0&&h[i][j]<h[i][j-1])
				sign=0;
			else if(j<n-1&&h[i][j]<h[i][j+1])
				sign=0;

			if(sign==1)
			{
				printf("%d %d\n",i,j);
			}
			else 
				continue;
		}
	}
}
int main(){
    int i,j,m,n,s,a[25][25],b[25][25];
    scanf("%d%d",&m,&n);
    for (i=0;i<=m+1;i++)
    for (j=0;j<=n+1;j++)
    {a[i][j]=0;b[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]))
          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;
}
char comp(int point, int up, int down, int left, int right)
{
	return ((point>=up)&&(point>=down)&&(point>=left)&&(point>=right));
}
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]);   // ??????????1~m??1~n?
	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]))
				printf("%d %d\n",j-1,k-1);
}
int main()
{
    int m,n;
    cin>>m>>n;
    int a[20][20];
    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||(i>0&&a[i-1][j]<=a[i][j]))
            {
                if(i==m-1||(i<m-1&&a[i+1][j]<=a[i][j]))
                {
                    if(j==0||(j>0&&a[i][j-1]<=a[i][j]))
                    {
                        if(j==n-1||(j<n-1&&a[i][j+1]<=a[i][j]))
                        {
                            cout<<i<<" "<<j<<endl;
                        }
                    }
                }
            }
        }
    }
    
    return 0;
}
int main()
{
	int m,n;
	int i,j;
	int a[21][21];
	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&&a[i][j]>=a[i-1][j])||(i==0))
				if((i<m-1&&a[i][j]>=a[i+1][j])||(i==m-1))
					if((j>0&&a[i][j]>=a[i][j-1])||(j==0))
						if((j<n-1&&a[i][j]>=a[i][j+1])||(j==n-1))
							cout<<i<<" "<<j<<endl;
		}
	}
	return 0;
}
int main(){
	int sz[21][21];
	int n,m,i,j,s=0,l=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			scanf("%d",&(sz[i][j]));
		}
	}
	for(j=0;j<=m+1;j++){
		sz[0][j]=4;
		sz[n+1][j]=4;
	}
	for(j=0;j<=n+1;j++){
		sz[j][0]=4;
		sz[j][m+1]=4;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;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,p=0,a[23][23],i=0,j=0,b[401],c[401];
	cin>>m>>n;
	for(j=0;j<=n+1;j++)
	{
		a[0][j]=0;
		a[m+1][j]=0;
	}
	for(i=0;i<=m+1;i++)
	{
		a[i][0]=0;
		a[i][n+1]=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])
                {    
					b[p]=i-1;
					c[p]=j-1;
					p++;
                }
			}
			for(i=0;i<p;i++)
			{
				cout<<b[i]<<" "<<c[i]<<endl;
			}
			return 0;
}
int main(){
	int m,n,a[1000][1000],b[1000][2],i,j,x=0,e;
	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=0;i<=m+1;i++){
		for(j=0;j<=n+1;j++){
			a[0][j]=a[m+1][j]=a[i][0]=a[0][n+1]=0;
		}
	}
	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]){
				b[x][0]=i-1;
				b[x][1]=j-1;
				x++;
			}

		}
	}

	for(i=0;i<x;i++){
		printf("%d %d\n",b[i][0],b[i][1]);
	}
}
main()
{
 int m,n;
 int a[22][22]={0};
 scanf("%d %d",&m,&n);
 for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
                     scanf("%d",&a[i+1][j+1]);
 for(int i=0;i<m;i++)
              for(int j=0;j<n;j++)
                       if(a[i+1][j+1]>=a[i+1][j]&&a[i+1][j+1]>=a[i][j+1]&&a[i+1][j+1]>=a[i+2][j+1]&&a[i+1][j+1]>=a[i+1][j+2])
                       printf("%d %d\n",i,j);
 getchar();
 getchar();
 getchar();
}
int main()
{
	int m,n,i,j,a[22][22];
	scanf("%d %d",&m,&n);
	for(j=0;j<n+2;j++)
	{
		a[0][j]=-1;
		a[m+1][j]=-1;
	}
	for(i=1;i<m+1;i++)
	{
		a[i][0]=-1;
		a[i][n+1]=-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++)
		{
			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[22][22],b[400][2];
    int n,m,num=0,i=0,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(j=0;j<n+2;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;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]) 
                {  
                   num+=1;
                   b[num-1][0]=i-1;
                   b[num-1][1]=j-1; 
                }
            } 
        }   
      for(i=0;i<num;i++)
      {
          
              printf("%d %d\n",b[i][0],b[i][1]);
          
      } 
    return 0; 
}
int main(){
 int n,m,i,j;
 int a[25][25];
 scanf("%d",&n);
 scanf("%d",&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&&j==0){
		    if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j+1])
				printf("%d %d\n",i,j);
		 }
		 if(i==0&&j==m-1){
		    if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1])
				printf("%d %d\n",i,j);
		 }
		 if(i==n-1&&j==0){
		    if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])
				printf("%d %d\n",i,j);
		 }
		 if(i==n-1&&j==m-1){
		    if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])
				printf("%d %d\n",i,j);
		 }
         if(i<n-1&&i>0&&j==0){
		    if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
				printf("%d %d\n",i,j);
		 }
		 if(i<n-1&&i>0&&j==m-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);
		 }
		 if(j<m-1&&j>0&&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);
		 }
		 if(j<m-1&&j>0&&i==n-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);
		 }
		 if(j<m-1&&j>0&&i<n-1&&i>0){
		    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);
		 }
	 }
 }
 
 return 0;
 
}
int shan[max][max]={0};
int main()
{
	int h,l;
	cin>>h>>l;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=l;j++)
			cin>>shan[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=l;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;
			
		
		
}
int main()
{
   int m,n;
   int sz[20][20];
   int i,k;
  

   scanf("%d %d",&m,&n);
   for(k=0;k<m;k++)
   {
     for(i=0;i<n;i++)
	 {
		 scanf("%d",&sz[k][i]);
	 }
   }

   for(k=0;k<m;k++)
   {
	  
	 if(k==0)
	 {
		 
		
	for(i=0;i<n;i++)
	   {
				if(i==0)
		 {
			 
		   if((sz[k][i]>=sz[k+1][i])&&(sz[k][i]>=sz[k][i+1]))
			  printf("%d %d\n",k,i);
		 }
		 else if(i==n-1)
		 {
		   if((sz[k][i]>=sz[k+1][i])&&(sz[k][i]>=sz[k][i-1]))
			   printf("%d %d\n",k,i);
		 }
		 else
		 {
	          if((sz[k][i]>=sz[k+1][i])&&(sz[k][i]>=sz[k][i-1])&&(sz[k][i]>=sz[k][i+1]))
				 printf("%d %d\n",k,i);
			}
	    }
		
	 }
	 if((k!=0)&&(k!=m-1))
	 {
		 
		 
           for(i=0;i<n;i++)
	         {
				 if(i==0)
		 {
		   if((sz[k][i]>=sz[k+1][i])&&(sz[k][i]>=sz[k][i+1])&&(sz[k][i]>=sz[k-1][i]))
			  printf("%d %d\n",k,i);
		 }
		 else if(i==n-1)
		 {
		   if((sz[k][i]>=sz[k+1][i])&&(sz[k][i]>=sz[k][i-1])&&(sz[k][i]>=sz[k-1][i]))
			 printf("%d %d\n",k,i);
		 }
		 else
		 {
	           if((sz[k][i]>=sz[k-1][i])&&(sz[k][i]>=sz[k+1][i])&&(sz[k][i]>=sz[k][i-1])&&(sz[k][i]>=sz[k][i+1]))
		         printf("%d %d\n",k,i);
		 }
	    }
	 }
	 if(k==m-1)
	 {
	   
		    for(i=0;i<n;i++)
			{
				if(i==0)
		 {
		   if((sz[k][i]>=sz[k-1][i])&&(sz[k][i]>=sz[k][i+1]))
			   printf("%d %d\n",k,i);
	     }
		 else if(i==n-1)
		 {
		   if((sz[k][i]>=sz[k-1][i])&&(sz[k][i]>=sz[k][i-1]))
			   printf("%d %d\n",k,i);
		 }
		 else
		 {
	          if((sz[k][i]>=sz[k-1][i])&&(sz[k][i]>=sz[k][i-1])&&(sz[k][i]>=sz[k][i+1]))
				  printf("%d %d\n",k,i);
			}
		 }
	 }
   }
  
   return 0;
}
int main()
{
	int m,n,i,j;
	cin>>m>>n;
	int x[21][21];
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
			cin>>x[i][j];
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if((i==0)&&(j==0)&&(x[0][0]>=x[0][1])&&(x[0][0]>=x[1][0])) cout<<i<<" "<<j<<endl;
			else if((i==0)&&(j<n-1)&&(j>0)&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i+1][j])&&(x[i][j]>=x[i][j+1])) cout<<i<<" "<<j<<endl;
			else if((i==m-1)&&(j<n-1)&&(j>0)&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i][j+1])&&(x[i][j]>=x[i-1][j])) cout<<i<<" "<<j<<endl;
			else if((j==0)&&(i>0)&&(i<m-1)&&(x[i][j]>=x[i+1][j])&&(x[i][j]>=x[i][j+1])&&(x[i][j]>=x[i-1][j])) cout<<i<<" "<<j<<endl;
			else if((j==n-1)&&(i>0)&&(i<m-1)&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i-1][j])&&(x[i][j]>=x[i+1][j])) cout<<i<<" "<<j<<endl;
			else if((i==0)&&(j==n-1)&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i+1][j])) cout<<i<<" "<<j<<endl;
			else if((i==m-1)&&(j==0)&&(x[i][j]>=x[i-1][j])&&(x[i][j]>=x[i][j+1])) cout<<i<<" "<<j<<endl;
			else if((i==m-1)&&(j==n-1)&&(x[m-1][n-1]>=x[m-2][n-1])&&(x[m-1][n-1]>=x[m-1][n-2])) cout<<i<<" "<<j<<endl;
			else if((x[i][j]>=x[i+1][j])&&(x[i][j]>=x[i-1][j])&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i][j+1])) cout<<i<<" "<<j<<endl;
		}
	}
	return 0;
}
int main()
{
    int i,j,m,n,a[20][20];
    cin>>m>>n;
    for(i=0;i<m;i++)
    for(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;
              if(j!=0)
              {
                  for(j=1;j<n-1;j++)
                {
                    if(a[0][j]>=a[1][j]&&a[0][j]>=a[0][j-1]&&a[0][j]>=a[0][j+1])
                    cout<<"0 "<<j<<endl;
                }
              }
              if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1])
                cout<<"0 "<<n-1<<endl;

    for(i=1;i<m-1;i++)
    for(j=0;j<n;j++)
    {

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

for(i=1;i<=m;i++){
	for(j=1;j<=n;j++){
		if(ma[i][j]>=ma[i-1][j]&&ma[i][j]>=ma[i+1][j]&&ma[i][j]>=ma[i][j+1]&&ma[i][j]>=ma[i][j-1]){
			cout<<i-1<<" "<<j-1<<endl;
		}
	}
}

return 0;


}
int main(){
  int m,n,i,j,k,p,a[22][22];
   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=0;i<m+2;i++){
        for(j=0;j<n+2;j++){
            a[i][0]=a[0][j]=a[m+1][j]=a[i][n+1]=0;
        }
    }
      for(i=1;i<m+1;i++){
         for(j=1;j<n+1;j++){
        if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]){
      printf("%d %d\n",i-1,j-1);
    }
   }
  }
  return 0;
}
/*
 * ????
 * Created on: 2013-1-13
 * ??
 * Author: ???
 */
int main() {
	int r = 0, c = 0;
	cin >> r >> c;
	int mountain[r + 2][c + 2];
	for (int i = 0; i < r + 2; i++)
		for (int j = 0; j < c + 2; j++) {
			if (i == 0 || j == 0 || i == r + 1 || j == c + 1)
				mountain[i][j] = 0;
			else
				cin >> mountain[i][j];
		}
	for (int i = 1; i < r + 1; i++)
		for (int j = 1; j < c + 1; j++) {
			if ((mountain[i][j] >= mountain[i - 1][j]) && (mountain[i][j]
					>= mountain[i + 1][j]) && (mountain[i][j] >= mountain[i][j
					- 1]) && (mountain[i][j] >= mountain[i][j + 1]))
			cout << i-1 << " " << j-1 << endl;
		}
	return 0;
}
int main()
{
	int n,m,i,j,k,l,sum=0;
	cin>>m>>n;
	int a[1000][1000];
	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][j+1] && a[i][j]>=a[i+1][j])
				{
					cout<<i<<" "<<j<<endl;
				}
				else if(j==n-1 && 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][j-1] && 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)
			{
				if(j==0 && 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 && 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][j-1] && 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(i==m-1)
			{
				if(j==0 && a[i][j]>=a[i][j+1] && a[i][j]>=a[i-1][j])
				{
					cout<<i<<" "<<j<<endl;
				}
				else if(j==n-1 && 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][j-1] && a[i][j]>=a[i-1][j] && a[i][j]>=a[i][j+1])
				{
					cout<<i<<" "<<j<<endl;
				}
			}
		}
	}
}
int main()
{
int m,n;
scanf("%d %d",&m,&n);
int sz[m][n];
int row,col;
for(row=0;row<m;row++){
  for(col=0;col<n;col++){
     scanf("%d ",&sz[row][col]);
  }
}
int a[400],b[400];
int i;
i=0;
for(row=0;row<m;row++){
  for(col=0;col<n;col++){
    if(row==0&&col==0){
       if(sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row+1][col]){
                 a[i]=row;
                 b[i]=col;
                 i++; 
       }
    }
    else if(row==0&&col==n-1){
        if(sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row+1][col]){
                a[i]=row;
                 b[i]=col;
                 i++; 
         }
    }
    else if(row==m-1&&col==0){
        if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col+1]){
                a[i]=row;
                 b[i]=col;
                 i++; 
         }
     }
    else if(row==m-1&&col==n-1){
        if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col-1]){
               a[i]=row;
                 b[i]=col;
                i++; 
         }
     }
    else if(row==0){
         if(sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]){ 
           a[i]=row;
           b[i]=col;
            i++; 
         }
     }
    else if(row==m-1){
          if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]){
             a[i]=row;
           b[i]=col; 
             i++; 
         }
     }
    else if(col==0){
          if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col+1]){
             a[i]=row;
           b[i]=col; 
            i++; 
         }
     }
     else if(col==n-1){
           if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]){
            a[i]=row;
           b[i]=col; 
            i++; 
         }
     }
     else if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]){
       a[i]=row;
       b[i]=col;
       i++; 
     }
   
   }
}
int k;
for( k = 0;k < i; k++ ){
      printf("%d %d\n",a[k],b[k]);
}
return 0;
}
int h[20][20];
int sort(int l,int r)
{if(l>0)
{if(h[l-1][r]>h[l][r])
return 0;}
if(l<19)
{if(h[l+1][r]>h[l][r])
return 0;}
if(r>0)
{if(h[l][r-1]>h[l][r])
return 0;}
if(r<19)
{if(h[l][r+1]>h[l][r])
return 0;}
return 1;}
int main()
{int m,n,i,j;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++)
	{for(j=0;j<n;j++)
{scanf("%d",&h[i][j]);}}
for(i=0;i<m;i++)
	{for(j=0;j<n;j++)
{if(sort(i,j)==1)
printf("%d %d\n",i,j);}}
}
int main()
{
    int m,n,a[100][100];
    cin>>m>>n;
    for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++)
    {
            cin>>a[i][j];
    }
    for(int i=0;i<=m+1;i++) a[i][0]=-1,a[i][n+1]=-1;
    for(int j=1;j<=m;j++) a[0][j]=-1,a[m+1][j]=-1;
    a[0][0]=-2;
    a[0][n+1]=-2;
    a[m+1][0]=-2;
    a[m+1][n+1]=-2;
    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,p=0,sz1[22][22],sz2[400],sz3[400],i,j; 
scanf("%d%d",&m,&n);
for(i=0;i<=m-1;i++)
    {
	for(j=0;j<=n-1;j++)
		{
		scanf("%d",&sz1[i][j]);
		}
	}
for(j=-1;j<=n;j++)
	{
	sz1[-1][j]=-1;
	sz1[m][j]=-1;
	}
for(i=-1;i<=m;i++)
	{
	sz1[i][-1]=-1;
	sz1[i][n]=-1;
	}
for(i=0;i<=m-1;i++)
	{
	for(j=0;j<=n-1;j++)
		{
		if(sz1[i][j]>=sz1[i-1][j]&&sz1[i][j]>=sz1[i][j-1]&&sz1[i][j]>=sz1[i][j+1]&&sz1[i][j]>=sz1[i+1][j])
			{
			sz2[p]=i;
			sz3[p]=j;
			p++;
			}
		}
	}
for(i=0;i<=p-1;i++)
	{
	printf("%d %d\n",sz2[i],sz3[i]);
	}
return 0;
}