semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void sort (int *data,int n)
{
     int i,j,*min,t;
     for (i=0;i<n;i++)
     {
         min=data+i;
         for (j=i;j<n;j++)
         {
             if (*(data+j)<*min)
             min=data+j;
         }
         t=*(data+i);
         *(data+i)=*min;
         *min=t;
     }
}
int main ()
{
    int n,m,s=0,c=0,j,i,k=0;
    scanf("%d %d",&m,&n);
    int a[m+2][n+2],b[500];
    
    for (i=0;i<m+2;i++)
    {
        for (j=0;j<n+2;j++)
        {
            a[i][j]=0;
        }
    }
    for (i=0;i<=500;i++)
    {
        b[k]=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+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])
            {
               b[k]=100*i+j;
               k++;
            }
        }
    }
    
    sort (b,k);
    for (i=0;i<k;i++)
    {
        printf ("%d %d\n",b[i]/100-1,b[i]%100-1);
    }
    

    return 0;
    
}
//**********************************
//??: ????
//???2013.12.18
//**********************************
int main()
{
	int m=0,n=0,i=0,j=0,a[22][22]={0},b[400][2],p=0,q=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])
			{
				b[p][0]=i;
				b[p][1]=j;
				p++;
			}
			else
				continue;
		}
	for(i=0;i<p;i++)
	    cout<<b[i][0]-1<<" "<<b[i][1]-1<<endl;
    return 0;
}
int main()
{
	int m,n;
	cin>>m>>n;
	int a[22][22];
	int i,j;
	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;
	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])
			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(i=1;i<m-1;i++)
	{
		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;
		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])
			{
				cout<<i<<' '<<j<<endl;
			}
		}
		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])
			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;
	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])
			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 moun[30][30];
int high[30][30];
int main()
{
	int row,col;
	cin>>row>>col;

	for(int i=0;i<=row+1;i++)
		for(int j=0;j<=col+1;j++)
		 moun[i][j]=0;

	for(int i=1;i<=row;i++)
		for(int j=1;j<=col;j++)
			cin>>moun[i][j];

	for(int i=1;i<=row;i++)
		for(int j=1;j<=col;j++)
			if(moun[i][j]>=moun[i-1][j] && moun[i][j]>=moun[i][j-1] && moun[i][j]>=moun[i+1][j] && moun[i][j]>=moun[i][j+1])
				cout<<i-1<<" "<<j-1<<endl;
	 


	return 0;
}
int main() {
	int m,n;
	int i,j;

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

int high(int x,int y)
{
	if(x!=0 && a[x-1][y]>a[x][y]) return 0;
	if(y!=0 && a[x][y-1]>a[x][y]) return 0;
	if(x!=m && a[x+1][y]>a[x][y]) return 0;
	if(y!=n && a[x][y+1]>a[x][y]) return 0;
	return 1;
}

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++)
			if(high(i,j)==1)
				cout<<i<<' '<<j<<endl;
	return 0;
}
int main()
{
	int a[22][22], m, n;
	cin >> m >> n;
	for (int i = 0; i <= m + 1; i++)
	{
		for (int j = 0; j <= n + 1; j++)
		{
			if (i == 0 || i == m + 1 || j == 0 || j == n + 1)
			{
				a[i][j] = 0;
			}
			else
			{
				cin >> a[i][j];
			}
		}
	}
	for (int k = 1; k <= m; k++)
	{
		for (int l = 1; l <= n; l++)
		{
			if (a[k][l] >= a[k - 1][l] && a[k][l] >= a[k + 1][l] && a[k][l] >= a[k][l + 1] && a[k][l] >= a[k][l - 1])
			{
				cout << k - 1 << ' ' << l - 1 << endl;
			}
		}
	}
	return 0;
}
int main()
{	
	int num[22][22],i,j,m,n;
	while(cin >> m >> n)
	{
		memset(num,0,sizeof(num));
	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][j-1])&&(num[i][j]>=num[i][j+1])&&(num[i][j]>=num[i+1][j])&&(num[i][j]>=num[i-1][j]))
			{
				cout << i-1 << " " << j-1  << endl;
			}
		}
	}
	}
	return 0;
}
int main()
{
    int m,n,i,q;
    scanf("%d%d",&m,&n);
    int qq[m+2][n+2];
    for(i=1;i<m+1;i++)
    {
        for(q=1;q<n+1;q++)
        {
            scanf("%d",&qq[i][q]);
        }
    }
    for(i=0;i<n+2;i++)
    {
        qq[0][i]=qq[m+1][i]=0;
    }
    for(i=0;i<m+2;i++)
    {
        qq[i][0]=qq[i][n+1]=0;
    }
    for(i=1;i<m+1;i++)
    {
        for(q=1;q<n+1;q++)
        {
            if(qq[i][q]>=qq[i-1][q]&qq[i][q]>=qq[i+1][q]&qq[i][q]>=qq[i][q-1]&qq[i][q]>=qq[i][q+1])
            {
                printf("%d %d\n",i-1,q-1);
            }
            else
            {
                i=i;
                q=q;
            }
        }
    }
    return 0;
}
//============================================================================
// Name        : abc.cpp
// Author      : aaa
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================


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

}
int main()
{
	int a[100][100],m,n,i,j;
	cin >>m>>n;
	for(j=0;j<m;j++)
	{
		for(i=0;i<n;i++)
			cin>>a[j][i];
	}
	for(j=0;j<m;j++)
		for(i=0;i<n;i++)
		{
			if(j==0&&i!=0)
			{
				if(a[j][i]>=a[j][i-1]&&a[j][i]>=a[j][i+1]&&a[j][i]>=a[j+1][i])
					cout<<j<<" "<<i<<endl;
			}
			else if(j==0&&i==0)
			{
				if(a[j][i]>=a[j][i+1]&&a[j][i]>=a[j+1][i])
					cout<<j<<" "<<i<<endl;
			}
			else 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;
		}
		return 0;
}
int main(){
 int n,m,i,j,a[100][100];
 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){
    if(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(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])) 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(i<m-1){
    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][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);}
    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(i==m-1){
    if(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(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])) 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",i,j);}
   }
  }
 }
  return 0;
}
int main()
{
	int a[21][21]={0};
	int b[500][2]={0};
	int m,n,i,j,k=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])
			{b[k][0]=i;b[k][1]=j;k++;}
	for(i=0;i<k;i++)
	{cout<<b[i][0]-1<<" "<<b[i][1]-1<<'\n';}
	return 0;
}
//============================================================================
// Name        : xunzhaoshanding.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================



int main() {
	int m,n;
	int a[21][21];
	cin>>m;
	cin>>n;
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	if(a[0][0]>=a[1][0]&&a[0][0]>=a[0][1])cout<<0<<' '<<0<<endl;

	for(int c=1;c<n-1;c++)
		if(a[0][c]>=a[0][c-1]&&a[0][c]>=a[0][c+1]&&a[0][c]>=a[1][c])cout<<0<<' '<<c<<endl;

	if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1])cout<<0<<' '<<n-1<<endl;

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

				else if(j==n-1)
								{
									if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j])cout<<i<<' '<<j<<endl;
							    }
				else
				{
					if(a[i][j]>=a[i][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-2][0]&&a[m-1][0]>=a[m-1][1])cout<<m-1<<' '<<0<<endl;

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

	
    for (i=1;i<m+1;i++)
	{
		
		for (j=1;j<n+1;j++)
		{
			if (s[i][j]>=s[i+1][j]&&s[i][j]>=s[i][j+1]&&s[i][j]>=s[i-1][j]&&s[i][j]>=s[i][j-1])
		    printf("%d %d\n",i-1,j-1);
		}
		

	}
    
	return 0;
}
/*
 * 00004.cpp
 *
 *  Created on: 2013-12-13
 *      Author: Administrator
 ???m×n??????????????????????????????????????????????????
 ?????????????????????)?
????
???????????????m?5?m?20???n?5?n?20??
??m????m×n????????????????????????????????
????
?????????????????????m???????n???????????
????
10 5
0 76 81 34 66

1 13 58 4 40

5 24 17 6 65

13 13 76 3 20

8 36 12 60 37

42 53 87 10 65

42 25 47 41 33

71 69 94 24 12

92 11 71 3 82

91 90 20 95 44

????
0 2

0 4

2 1

2 4

3 0

3 2

4 3

5 2

5 4

7 2

8 0

8 4

9 3
*/
int main(){
	int m,n;
	int str[20][20];
	cin>>m>>n;
	for(int i=0;i<m;i++)
	for(int j=0;j<n;j++)
		cin>>str[i][j];
	for(int i=0;i<m;i++)
	for(int j=0;j<n;j++)
	{
		if(i==0&&j==0){
			if((str[0][0]>=str[0][1])&&(str[0][0]>=str[1][0]))
		          cout<<i<<" "<<j<<endl;
		}
		else if(i==0&&j==n-1){
			if((str[0][n-1]>=str[1][n-1])&&(str[0][n-1]>=str[0][n-2]))
				cout<<i<<" "<<j<<endl;
		}
		else if(i==m-1&&j==n-1){
					if((str[m-1][n-1]>=str[m-2][n-1])&&(str[m-1][n-1]>=str[m-1][n-2]))
						cout<<i<<" "<<j<<endl;
				}
		else if(i==m-1&&j==0){
					if((str[m-1][0]>=str[m-2][0])&&(str[m-1][0]>=str[m-1][1]))
						cout<<i<<" "<<j<<endl;
				}
		else if(i==0){
			if((str[0][j]>=str[0][j-1])&&(str[0][j]>=str[1][j])&&(str[i][j]>=str[0][j+1]))
					cout<<i<<" "<<j<<endl;
		}
		else if(j==0){
			if((str[i][j]>=str[i-1][j])&&(str[i][j]>=str[i+1][j])&&(str[i][j]>=str[i][j+1]))
						cout<<i<<" "<<j<<endl;
		}
		else if(i==m-1){
			if((str[i][j]>=str[i-1][j])&&(str[i][j]>=str[i][j-1])&&(str[i][j]>=str[i][j+1]))
						cout<<i<<" "<<j<<endl;
		}
		else if(j==n-1){
			if((str[i][j]>=str[i-1][j])&&(str[i][j]>=str[i][j-1])&&(str[i][j]>=str[i+1][j]))
						cout<<i<<" "<<j<<endl;
		}
		else{
		if((str[i][j]>=str[i-1][j])&&(str[i][j]>=str[i][j-1])&&(str[i][j]>=str[i+1][j])&&(str[i][j]>=str[i][j+1]))
			cout<<i<<" "<<j<<endl;}
	}
	return 0;
}
int main(){
	int n,m,a[21][21];
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	} 
	for(int i=0;i<=n+1;i++){
		for(int j=0;j<=m+1;j++){
			if(i==0||j==0||i==n+1||j==m+1) a[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;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;
}
main()
{
      int m,n;
      int a[20][20];
      scanf("%d %d",&m,&n);
      for (int i=0;i<m;i++)
         for (int j=0;j<n;j++)
           scanf("%d",&a[i][j]);
      for (int i=0;i<m;i++)
         for (int j=0;j<n;j++)
         {
             if (i==0)
             {
                      if (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 (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 if (i==m-1)
             {
                  if (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 (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 
             {
                  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);
                  }
             }
         }
      getchar();
      getchar();
}
int main(){
    int an[30][30];
	int m,n,i,j;
	char x;
	x=' ';
	scanf("%d%d",&m,&n);
	for(i=0;i<30;i++){
		for(j=0;j<30;j++)
			an[i][j]=0;
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++)
			scanf("%d",&an[i][j]);
	}
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(an[i][j]>=an[i-1][j]&&an[i][j]>=an[i+1][j]&&an[i][j]>=an[i][j-1]&&an[i][j]>=an[i][j+1])
				printf("%d%c%d\n",i-1,x,j-1);
		}
	}
	return 0;
}
int main(){
	int m,n;
	cin>>m>>n;
	int mountain[m+2][n+2];
	
	for(int i=0;i<m+2;i++){
		for(int j=0;j<n+2;j++){
			if(i!=0&&j!=0&&i!=m+1&&j!=n+1) cin>>mountain[i][j];
			else mountain[i][j]=-1;
		}
	}
	
	for(int i=1;i<m+1;i++){
		for(int j=1;j<n+1;j++){
			if(mountain[i][j]!=-1){
				if(!(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]>mountain[i][j])){
				cout<<i-1<<" "<<j-1<<endl;
				}
			}
		}
	}
}
int main()
{
	int a[20][20],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==0 && j==0)
			{
				if(a[i+1][0] <= a[i][j] && a[0][j+1] <= a[i][j])
				{
					cout << i << " " << j << endl;
				}
			}
			else if(i ==0 && j == n-1)
			{
				if(a[0][j-1] <= a[0][j] && a[1][j] <= a[0][j])
				{
					cout << i << " " << j << endl;
				}
			}
			else if(i == m-1&&j == 0)
			{
				if(a[i][j] >= a[i-1][j] &&a[i][j] >= a[i][j+1])
				{
					cout <<i<< " "<< j << endl;
				}
			}
			else if(i == m-1&&j == n-1)
			{
				if(a[i][j] >=a[i][j-1] && a[i][j]>=a[i-1][j])
				{
					cout << i<< " " << j << endl;
				}
			}
			else if(i == 0)
			{
				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(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+1][j] && a[i][j] >= a[i][j+1])
				{
					cout << i << " " << j << endl;
				}
			}
			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])
				{
					cout << i << " " << j << endl;
				}
			}
			else
			{
				if(a[i][j] >= a[i-1][j]&&a[i][j] >= a[i+1][j] && a[i][j] >= a[i][j-1]&&a[i][j]>=a[i][j+1])
				{
					cout << i << " "<< j<< endl;
				}
			}
		}
	}
	return 0;
}
int main(){
	int k,m,n,i,l,j,x,z,o,p,q,r,s;
	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]));
		}
	}
	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]))
	{x=n-1;
	printf("0 %d\n",x);}
	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-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,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]))
		{   z=n-1;
			printf("%d %d\n",i,z);
		}
}
	if((a[m-1][0]>=a[m-1][1])&&(a[m-1][0]>a[m-2][0]))
	{
		o=m-1;
		printf("%d 0\n",o);
	}
	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]))
		{
			p=m-1;
			printf("%d %d\n",p,i);
	}
	}
	if((a[m-1][n-1]>=a[m-1][n-2])&&(a[m-1][n-1]>a[m-2][n-1]))
	{q=m-1;
	r=n-1;
	printf("%d %d\n",q,r);}
	return 0;
}
int main(){
	int i,n,m,j,k=0,f;
	int sz[25][25],q[25][25],w[25],s[25];
	scanf("%d %d",&m,&n);
	for(i=0;i<m;i++){
	for(j=0;j<n;j++){
		scanf("%d",&sz[i][j]);}
	}
	for(i=0;i<m+2;i++){
	for(j=0;j<n+2;j++){
		 q[0][j]=0,q[m+1][j]=0,q[i][0]=0,q[i][n+1]=0;
		q[i+1][j+1]=sz[i][j];}}
	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-1][j]&&q[i][j]>=q[i][j+1]&&q[i][j]>=q[i][j-1]){
	
			printf("%d %d\n",i-1,j-1);}}}
	
return 0;
}
void check(int m,int n,int h[20][20])
{
	int i,j;
	for(i=0;i<=m-1;i++)
		for(j=0;j<=n-1;j++)
		{
			int x=1;
			if(i!=0&&h[i][j]<h[i-1][j]) x=0;
			if(i!=m-1&&h[i][j]<h[i+1][j]) x=0;
			if(j!=0&&h[i][j]<h[i][j-1]) x=0;
			if(j!=n-1&&h[i][j]<h[i][j+1]) x=0;

			if(x==1) printf("%d %d\n",i,j);
		}
}

void main(void)
{
	int m,n,i,j,h[20][20];
	scanf("%d%d",&m,&n);

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

	check(m,n,h);
}