semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//********************************
//*???10??                 **
//*??????                 **
//*???2012.1.11              **
//*******************************/

int main ()
{
	int m, n, hei[20][20], i, j;
	cin >> m >> n;
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++)
			cin >> hei[i][j];
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++)
		{
			if (j != 0 && hei[i][j] < hei[i][j - 1])
				continue;
			if (j != n - 1 && hei[i][j] < hei[i][j + 1])
				continue;
			if (i != 0 && hei[i][j] < hei[i - 1][j])
				continue;
			if (i != m - 1 && hei[i][j] < hei[i + 1][j])
				continue;
			cout << i << " " <<j << endl;
		}
	return 0;
}
int main(){
	int m,n,i,j;
	scanf("%d %d",&m,&n);
	m=m+2;
	n=n+2;
    int a[22][22];
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(i==0||i==m-1||j==0||j==n-1){
				a[i][j]=0;
                          }
		}
	}
			for(i=1;i<m-1;i++){
				for(j=1;j<n-1;j++){
            scanf("%d",&a[i][j]);
		}
	}
for(i=1;i<m-1;i++){
	for(j=1;j<n-1;j++){
			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 n,m,i,j,k,a[22][22];
    float avg;
    cin>>m>>n;
    for(i=0;i<22;i++)
    {
         for(j=0;j<22;j++)
         {
              a[i][j]=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][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
              {
                   cout<<i-1<<" "<<j-1<<endl;
              }
         }
    }
    cin>>n;
    return 0;
}
int main()
{
	int a[22][22], i, j, m, n;
	cin >> m >> n;
	for(i=1; i <= m; i++)
		for(j=1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	for(i=0; i<22; i++)
	{
		a[0][i]=0;
		a[m+1][i]=0;
		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])
				cout << i-1 << " " << j-1 << endl;
		}
	return 0; 
}
int main()
{
	int num[22][22];
	memset(num,0,sizeof(num));
	int n=0,m=0;
	int i=0,j=0;
	cin>>m>>n;
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			cin>>num[i][j];
	for(j=1;j<=m;j++)
		for(i=1;i<=n;i++)
			if(num[j][i]>=num[j-1][i]&&num[j][i]>=num[j+1][i]&&num[j][i]>=num[j][i+1]&&num[j][i]>=num[j][i-1])
				cout<<j-1<<" "<<i-1<<endl;
	return 0;
}
int main(){
	int m,n,i,j,sz[22][22];
	scanf("%d%d",&m,&n);
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	for(i=0;i<=m+1;i++){
		for(j=0;j<=n+1;j++){
            if(i==0||i==m+1||j==0||j==n+1){
		        sz[i][j]=0;
			}
		}
	}
	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,i,j,o;
    scanf("%d",&m);
    scanf("%d",&n);
    o=0;
    int a[m+2][n+2];
    for(i=0;i<m+2;i++)
    {
                      for(j=0;j<n+2;j++)
                      {
                                        a[i][j]=-10;
                      }
    }
    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]))
                                      {
                                                                                                                                if(o==0)
                                                                                                                                {
                                                                                                                                printf("%d %d\n",(i-1),(j-1));
                                                                                                                                o++;
                                                                                                                                }
                                                                                                                                else
                                                                                                                                {
                                                                                                                                printf("%d %d\n",(i-1),(j-1));
                                                                                                                                o++;
                                                                                                                                }
                                      }
                     }
   }
}
int main()
{
	int m,n;//m?n??????
	int map[20][20];
	int i,j;
	cin>>m>>n;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>map[i][j];
		}
	}
	for(i=0;i<n;i++)//???0????
	{
		if(i==0)
		{
			if(map[0][i]>=map[0][i+1]&&map[0][i]>=map[1][i])
				cout<<"0"<<" "<<i<<endl;
		}
		else if(i==n-1)
		{
			if(map[0][i]>=map[0][i-1]&&map[0][i]>=map[1][i])
				cout<<"0"<<" "<<i<<endl;
		}
		else
		{
			if(map[0][i]>=map[0][i-1]&&map[0][i]>=map[0][i+1]&&map[0][i]>=map[1][i])
				cout<<"0"<<" "<<i<<endl;
		}
	}
	for(i=1;i<m-1;i++)//???1?m-2????
	{
		for(j=0;j<n;j++)
		{
			if(j==0)
			{
				if(map[i][j]>=map[i-1][j]&&map[i][j]>=map[i+1][j]&&map[i][j]>=map[i][j+1])
					cout<<i<<" "<<j<<endl;
			}
			else if(j==n-1)
			{
				if(map[i][j]>=map[i-1][j]&&map[i][j]>=map[i+1][j]&&map[i][j]>=map[i][j-1])
					cout<<i<<" "<<j<<endl;
			}
			else
			{
				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])
					cout<<i<<" "<<j<<endl;
			}
		}
	}
	for(i=0;i<n;i++)//???m-1????
	{
		if(i==0)
		{
			if(map[m-1][i]>=map[m-1][i+1]&&map[m-1][i]>=map[m-2][i])
				cout<<(m-1)<<" "<<i<<endl;
		}
		else if(i==n-1)
		{
			if(map[m-1][i]>=map[m-1][i-1]&&map[m-1][i]>=map[m-2][i])
				cout<<(m-1)<<" "<<i<<endl;
		}
		else
		{
			if(map[m-1][i]>=map[m-1][i-1]&&map[m-1][i]>=map[m-1][i+1]&&map[m-1][i]>=map[m-2][i])
				cout<<(m-1)<<" "<<i<<endl;
		}
	}
	return 0;
}
int main()
{
	int m,n,gao[20][20],i,j;

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

	return 0;
}
int main()
{
    int height[30][30] = {0};
    int i, j, k, row, col;
    cin >> row >> col;
    for (i = 1; i <= row; i++)
     for (j = 1; j <= col; j++)
     {
         cin >> height[i][j];
     }
    int dir[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
    for (i = 1; i <= row; i++)
     for (j = 1; j <= col; j++)
     {
          for (k = 0; k < 4; k++)
          {
               int ii = i + dir[k][0];
               int jj = j + dir[k][1];
               if (height[i][j] < height[ii][jj])
               {
                   break;
               }
          }
          if (k == 4)
          {
              cout << i - 1 << " " << j - 1 << endl;
          }
     } 
     return 0;
}
int main()
{
	int x=0,y=0,i=0,j=0,avg=0;
	int h[22][22]={0};
	int outx[400],outy[400],count=0;
	cin>>x>>y;
	for(i=0;i<22;i++)
	{
		for(j=0;j<22;j++)
		{
			h[i][j]=0;
		}
	}
	for(i=1;i<=x;i++)
	{
		for(j=1;j<=y;j++)
		{
			cin>>h[i][j];
		}
	}
	for(i=1;i<=x;i++)
	{
		for(j=1;j<=y;j++)
		{
			if((h[i][j]>=h[i-1][j])&&(h[i][j]>=h[i+1][j])&&(h[i][j]>=h[i][j-1])&&(h[i][j]>=h[i][j+1]))
			{
				outx[count]=i;
				outy[count++]=j;
			}
		}
	}
	for(i=0;i<count;i++)
	{
		cout<<outx[i]-1<<" "<<outy[i]-1<<endl;
	}
	return 0;
}
int main()
{
	int m,n,h[22][22],i,j,b[22][22];
	cin>>m>>n;
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
		{
			cin>>h[i][j];
		
		}
    for(j=0;j<=n+1;j++)          //???????????????????????????0???????????
	{b[0][j]=0;b[m+1][j]=0;}
	for(i=1;i<m+1;i++)
	{b[i][0]=0;b[i][n+1]=0;}
	for(i=1;i<m+1;i++)
		for(j=1;j<n+1;j++)
			b[i][j]=h[i-1][j-1];
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
		{
			if(b[i][j]>=b[i-1][j]&&b[i][j]>=b[i+1][j]&&b[i][j]>=b[i][j+1]&&b[i][j]>=b[i][j-1])
				cout<<i-1<<" "<<j-1<<endl;
		}
	return 0;
}
char f(int x,int y,int a[20][20],int m,int n)
{
  char c;int i,t1=0,t2=0;
  int b[4]={0};char d[4]={'\0'};
  if(x-1>=0) {b[0]=1;t1++;if(a[x-1][y]<=a[x][y]) d[0]='t';}
  if(x+1<=m-1) {b[1]=1;t1++;if(a[x+1][y]<=a[x][y]) d[1]='t';}
  if(y-1>=0) {b[2]=1;t1++;if(a[x][y-1]<=a[x][y]) d[2]='t';}
  if(y+1<=n-1) {b[3]=1;t1++;if(a[x][y+1]<=a[x][y]) d[3]='t';}
  for(i=0;i<4;i++) {if(b[i]==1&&d[i]=='t') t2++;}
  if(t1==t2) c='t';
  else c='f'; 
  return c;
}
main()
{
  int m,n,i,j;
  scanf("%d %d",&m,&n);
  int a[20][20]={0},b[20][20]={0};
  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,a,m,n)=='t') b[i][j]=1;
    }
  }
  for(i=0;i<m;i++)
  {
    for(j=0;j<n;j++)
    {
      if(b[i][j]==1) printf("%d %d\n",i,j);
    }
  }
  getchar();
  getchar();
}
//ifstream fin("d:\\in.in");
int main(){
	int m,n,a[100][100],b[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=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
				b[i][j]=1;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			if(b[i][j])cout<<i-1<<' '<<j-1<<endl;
	return 0;
}
int main ()
{
	int i,j,m,n,p=0,z=0;
	 
	int sz[20][20];

	int e[1000],f[1000];
	
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d",&sz[i][j]);
	}
	}

			if(sz[0][0]>=sz[0][1]&&sz[0][0]>=sz[1][0]){

				e[z]=0;
				f[z]=0;
				z++;
				
			}
	for(j=1;j<n-1;j++){
			if(sz[0][j]>=sz[0][j+1]&&sz[0][j]>=sz[0][j-1]&&sz[0][j]>=sz[1][j]){
				e[z]=0;
				f[z]=j;
				z++;
				
		}
	}
			if(sz[0][n-1]>=sz[0][n-2]&&sz[0][n-1]>=sz[1][n-1]){
				e[z]=0;
				f[z]=n-1;
				z++;
				
			}
			for(i=1;i<m-1;i++){
				for(j=0;j<n;j++){
					if(j==0){
						if(sz[i][j]>=sz[i][1]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j]){
							e[z]=i;
							f[z]=j;
							z++;
						}
					}
					if(j!=0&&j!=n-1){
						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]){
							e[z]=i;
							f[z]=j;
							z++;
						}
					}
					if(j==n-1){
						if(sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j]){
							e[z]=i;
							f[z]=j;
							z++;
						}
					}
				}
			}

			if(sz[m-1][0]>=sz[m-2][0]&&sz[m-1][0]>=sz[m-1][1]){
				e[z]=m-1;
				f[z]=0;
				z++;
				
			}
	for(j=1;j<n-1;j++){
		if(sz[m-1][j]>=sz[m-1][j+1]&&sz[m-1][j]>=sz[m-1][j-1]&&sz[m-1][j]>=sz[m-2][j]){
				e[z]=m-1;
				f[z]=j;
				z++;
				
		}
		}

			if(sz[m-1][n-1]>=sz[m-2][n-1]&&sz[m-1][n-1]>=sz[m-1][n-2]){
				e[z]=m-1;
				f[z]=n-1;
				z++;
				
				
			}

	
    
	for(p=0;p<z;p++){
	
		printf("%d %d\n",e[p],f[p]);
	}
	

	return 0;

}
int main()
{
	int m,n;
	int MT[21][21];
	int Tx[401],Ty[401],x,y;
	int i,j,k=0;

	cin>>m>>n;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)cin>>MT[i][j];
	}

	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i+1<m && i-1>=0 && j+1<n && j-1>=0)
			{
				if(MT[i][j]>=MT[i+1][j] && MT[i][j]>=MT[i-1][j] && MT[i][j]>=MT[i][j+1] && MT[i][j]>=MT[i][j-1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i+1<m && i-1>=0 && j+1<n)
			{
				if(MT[i][j]>=MT[i+1][j] && MT[i][j]>=MT[i-1][j] && MT[i][j]>=MT[i][j+1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i+1<m && i-1>=0 && j-1>=0)
			{
				if(MT[i][j]>=MT[i+1][j] && MT[i][j]>=MT[i-1][j] && MT[i][j]>=MT[i][j-1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i+1<m && j+1<n && j-1>=0)
			{
				if(MT[i][j]>=MT[i+1][j] && MT[i][j]>=MT[i][j+1] && MT[i][j]>=MT[i][j-1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i-1>=0 && j+1<n && j-1>=0)
			{
				if(MT[i][j]>=MT[i-1][j] && MT[i][j]>=MT[i][j+1] && MT[i][j]>=MT[i][j-1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i==0 && j==0)
			{
				if(MT[i][j]>=MT[i+1][j] && MT[i][j]>=MT[i][j+1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i==0 && j==n-1)
			{
				if(MT[i][j]>=MT[i+1][j] && MT[i][j]>=MT[i][j-1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i==m-1 && j==0)
			{
				if(MT[i][j]>=MT[i-1][j] && MT[i][j]>=MT[i][j+1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}
			else if(i==m-1 && j==n-1)
			{
				if(MT[i][j]>=MT[i-1][j] && MT[i][j]>=MT[i][j-1])
				{
					Tx[k]=i;
					Ty[k]=j;
					k++;
				}
			}

		}
	}

	for(i=0;i<k;i++)
	{
		for(j=0;j<k-i-1;j++)
		{
			if(Tx[j]>Tx[j+1])
			{
				x=Tx[j];
				Tx[j]=Tx[j+1];
				Tx[j+1]=x;
				y=Ty[j];
				Ty[j]=Ty[j+1];
				Ty[j+1]=y;
			}
		}
	}

	for(i=0;i<k;i++)
	{
		for(j=0;j<k-i;j++)
		{
			if(Tx[j]==Tx[j+1] && Ty[j]>Ty[j+1])
			{
				y=Ty[j];
				Ty[j]=Ty[j+1];
				Ty[j+1]=y;
			}
		}
	}


	for(i=0;i<k;i++)cout<<Tx[i]<<" "<<Ty[i]<<endl;

	return 0;
}
int main()
{
	int m,n,i,j;
	scanf("%d %d",&m,&n);
	int sz[20][20];
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	if(sz[0][0]>=sz[0][1]&&sz[0][0]>=sz[1][0]) printf("0 0\n");
	for(j=1;j<n-1;j++){
		if(sz[0][j]>=sz[0][j-1]&&sz[0][j]>=sz[0][j+1]&&sz[0][j]>=sz[1][j]){
			printf("0 %d\n",j);
		}
	}	
	if(sz[0][n-1]>=sz[0][n-2]&&sz[0][n-1]>=sz[1][n-1]) printf("0 %d\n",n-1);
	for(i=1;i<m-1;i++){
		if(sz[i][0]>=sz[i][1]&&sz[i][0]>=sz[i-1][0]&&sz[i][0]>=sz[i+1][0]) printf("%d 0\n",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,j);
			}
		}	
		if(sz[i][n-1]>=sz[i][n-2]&&sz[i][n-1]>=sz[i-1][n-1]&&sz[i][n-1]>=sz[i+1][n-1]) printf("%d %d\n",i,n-1);
	}
	if(sz[m-1][0]>=sz[m-2][0]&&sz[m-1][0]>=sz[m-1][1]) printf("%d 0\n",m-1);
	for(j=1;j<n-1;j++){
		if(sz[m-1][j]>=sz[m-1][j-1]&&sz[m-1][j]>=sz[m-1][j+1]&&sz[m-1][j]>=sz[m-2][j]){
			printf("%d %d\n",m-1,j);
		}
	}	
	if(sz[m-1][n-1]>=sz[m-1][n-2]&&sz[m-1][n-1]>=sz[m-2][n-1]) printf("%d %d\n",m-1,n-1);
	return 0;
}
int main()
{
	int m,n;
	cin>>m>>n;
	int a[20][20];
	int x[400];
	int y[400];
	int t=0;
	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&&j==0)
			{
				if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			if(i==0&&j==n-1)
			{
				if(a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			if(i==m-1&&j==0)
			{
				if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])
				{
					x[t]=i;
			     	y[t]=j;
					t++;
				}
			}
			if(i==m-1&&j==n-1)
			{
				if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			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])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			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])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			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])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			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])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
			if(j>0&&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]&&a[i][j]>=a[i][j+1])
				{
					x[t]=i;
					y[t]=j;
					t++;
				}
			}
		}
	}
	for(int i=0;i<t;i++)
		cout<<x[i]<<' '<<y[i]<<endl;
	return 0;
}
int main()
{
	int m ,n ;
	scanf(" %d%d ",&m,&n);
	int i, j, k=0,p ;
	int a[100][100];
	int hs[100],ls[100];
	for(i=-1;i<m+1;i++)
	{
		for(j=-1;j<n+1;j++)
		{
			if(i==-1||i==m||j==-1||j==n)
				a[i][j]=0;
		}
	}
 	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(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])
			{
				hs[k]=i;
				ls[k]=j;
				k++;
			}
				
		}
	}
	for(p=0;p<k;p++)
		printf("%d %d\n",hs[p],ls[p]);


	return 0;



}
int main()
{
    int m,n,a[30][30],i,j;
    scanf("%d%d",&m,&n);
    for(i=0;i<m;i++)
     for(j=0;j<n;j++)
     scanf("%d",&a[i][j]);
    for(i=0;i<m;i++)
     for(j=0;j<n;j++)
     {
       if(i-1>=0)
       {
         if(a[i-1][j]>a[i][j])continue;
         }
       if(i+1<m)
       {
          if(a[i+1][j]>a[i][j])continue;      
                }
       if(j-1>=0)
       {
            if(a[i][j-1]>a[i][j])continue;   
            }
         if(j+1<n)
         {
               if(a[i][j+1]>a[i][j])continue; 
               }
               printf("%d %d\n",i,j);
               }
               getchar();
               getchar();
               }
int main()
{
	int m , n;
	int i, j, k;
	int a[23][23];
	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;
	}
	for(i = 0; 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-1][j] <= a[i][j] && a[i][j-1] <= a[i][j] && a[i+1][j] <= a[i][j] && a[i][j+1] <= a[i][j] )
				printf("%d %d\n",i-1,j-1);
		}
	return 0;
}
int main()
{
	int p[20][20], i, j, m, n;
	cin >> m >> n;
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
			cin >> p[i][j];
	}
	if (p[0][0] >= p[0][1] && p[0][0] >= p[1][0])
		cout << "0 0" << endl;
	for (i = 1; i < n - 1; i++)
	{
		if (p[0][i] >= p[0][i - 1] && p[0][i] >= p[0][i + 1] && p[0][i] >= p[1][i])
			cout << 0 << " " << i << endl;
	}
	if (p[0][n - 1] >= p[0][n - 2] && p[0][n - 1] >= p[1][n - 1])
		cout << 0 << " " << n - 1 << endl;
	for (i = 1; i < m - 1; i++)
	{
		if (p[i][0] >= p[i][1] && p[i][0] >= p[i + 1][0] && p[i][0] >= p[i - 1][0])
			cout << i << " 0" << endl;
		for (j = 1; j <= n - 2; j++)
		{
			if (p[i][j] >= p[i][j - 1] && p[i][j] >= p[i][j + 1] && p[i][j] >= p[i - 1][j] && p[i][j] >= p[i + 1][j])
				cout << i << " " << j << endl;
		}
		if (p[i][n - 1] >= p[i][n - 2] && p[i][n - 1] >= p[i - 1][n - 1] && p[i][n - 1] >= p[i + 1][n - 1])
			cout << i << " " << n - 1 << endl;
	}
	if (p[m - 1][0] >= p[m - 1][1] && p[m - 1][0] >= p[m - 2][0])
		cout << m - 1 << " " << 0 << endl;
	for (i = 1; i < n - 1; i++)
	{
		if (p[m - 1][i] >= p[m - 1][i - 1] && p[m - 1][i] >= p[m - 1][i + 1] && p[m - 1][i] >= p[m - 2][i])
			cout << m - 1 << " " << i << endl;
	}
	if (p[m - 1][n - 1] >= p[m - 1][n - 2] && p[m - 1][n - 1] >= p[m - 2][n - 1])
		cout << m - 1 << " " << n - 1 << endl;
	return 0;
}
int main()
{
	int n,m,i,j;
	int point[20][20];
	scanf("%d%d",&n,&m);
	for (i=0;i<n;i++)
	{
		for (j=0;j<m;j++)
		{
			scanf("%d",&point[i][j]);
		}
	}
	for (i=0;;)
	{
		for (j=0;;)
		{
			if (point[0][0]>=point[0][1]&&point[0][0]>=point[1][0])
			{
				printf("0 0\n");
			}
			break;
		}
		for (j=1;j<m-1;j++)
		{
			if (point[0][j]>=point[0][j-1]&&point[0][j]>=point[0][j+1]&&point[0][j]>=point[1][j])
			{
				printf("0 %d\n",j);
			}
		}
		for (j=m-1;;)
		{
			if(point[0][m-1]>=point[0][m-2]&&point[0][m-1]>=point[1][m-1])
			{
				printf("0 %d\n",m-1);
			}
			break;
		}
		break;
	}
	for (i=1;i<n-1;i++)
	{
		for (j=0;;)
		{
			if(point[i][0]>=point[i][1]&&point[i][0]>=point[i-1][0]&&point[i][0]>=point[i+1][0])
			{
				printf("%d 0\n",i);
			}
			break;
		}
		for (j=1;j<m-1;j++)
		{
			if (point[i][j]>=point[i-1][j]&&point[i][j]>=point[i][j-1]&&point[i][j]>=point[i+1][j]&&point[i][j]>=point[i][j+1])
			{
				printf("%d %d\n",i,j);
			}
		}
		for (j=m-1;;)
		{
			if (point[i][m-1]>=point[i][m-2]&&point[i][m-1]>=point[i-1][m-1]&&point[i][m-1]>=point[i+1][m-1])
			{
				printf("%d %d\n",i,m-1);
			}
			break;
		}
	}
	for (i=n-1;;)
	{
		for (j=0;;)
		{
			if (point[n-1][0]>=point[n-1][1]&&point[n-1][0]>=point[n-2][0])
			{
				printf("%d 0\n",n-1);
			}
			break;
		}
		for (j=1;j<m-1;j++)
		{
			if (point[n-1][j]>=point[n-1][j-1]&&point[n-1][j]>=point[n-1][j+1]&&point[n-1][j]>=point[n-2][j])
			{
				printf("%d %d\n",n-1,j);
			}
		}
		for (j=m-1;;)
		{
			if(point[n-1][m-1]>=point[n-1][m-2]&&point[n-1][m-1]>=point[n-2][m-1])
			{
				printf("%d %d\n",n-1,m-1);
			}
			break;
		}
		break;
	}
	return 0;
}
void main()
{
	int m,n,i,j,a[20][20],b[20][20],x[20][20];
	scanf("%d%d",&m,&n);
	for(i=0;i<20;i++)
		for(j=0;j<20;j++)
		{
			a[i][j]=0;b[i][j]=0;
		}
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			scanf("%d",&x[i][j]);

		for(j=1;j<n-1;j++)
		{
			if((x[0][j]>=x[0][j-1])&&(x[0][j]>=x[0][j+1])&&(x[0][j]>=x[1][j]))
			{b[0][j]=j;}
			if((x[m-1][j]>=x[m-1][j-1])&&(x[m-1][j]>x[m-1][j+1])&&(x[m-1][j]>=x[m-2][j]))
			{a[m-1][j]=m-1;b[m-1][j]=j;}
		}
	
		for(i=1;i<m-1;i++)
		{
			if((x[i][0]>=x[i-1][0])&&(x[i][0]>=x[i+1][0])&&(x[i][0]>=x[i][1]))
			{a[i][0]=i;}
			if((x[i][n-1]>=x[i-1][n-1])&&(x[i][n-1]>=x[i+1][n-1])&&(x[i][n-1]>=x[i][n-2]))
			{a[i][n-1]=i;b[i][n-1]=n-1;}
		}
		for(i=1;i<m-1;i++)
			for(j=1;j<n-1;j++)
			{if((x[i][j]>=x[i-1][j])&&(x[i][j]>=x[i][j-1])&&(x[i][j]>=x[i][j+1])&&(x[i][j]>=x[i+1][j]))
			{
				a[i][j]=i;
				b[i][j]=j;
			}
			}
	if((x[0][n-1]>=x[0][n-2])&&(x[0][n-1]>=x[1][n-1]))
	{b[0][n-1]=n-1;}
	if((x[m-1][0]>=x[m-1][1])&&(x[m-1][0]>=x[m-2][0]))
	{a[m-1][0]=m-1;}
	if((x[m-1][n-1]>=x[m-1][n-2])&&(x[m-1][n-1]>=x[m-2][n-1]))
	{a[m-1][n-1]=m-1;b[m-1][n-1]=n-1;}
	if((x[0][0]>=x[0][1])&&(x[0][0]>=x[1][0]))printf("0 0\n");
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			if((a[i][j]!=0)||(b[i][j]!=0))
				printf("%d %d\n",a[i][j],b[i][j]);
}
int main()
/*?? 
???m×n?????????????????????????????????????????????????????
??????????????????)?
 
???? 
???????????????m?5?m?20???n?5?n?20?? 
??m????m×n????????????????????????????????
 
???? 
?????????????????????m???????n??????????? */
{
	int mount[22][22];
	int i,j,s=0;
	int m,n;
	int temp;
	int pr[400],pc[400];

	for (i=0;i<22;i++)
		for (j=0;j<22;j++)
			mount[i][j]=0;
	cin >> m >> n;
	for (i=1;i<=m;i++)
		for (j=1;j<=n;j++)
			cin >> mount[i][j];
	for (i=1;i<=m;i++)
		for (j=1;j<=n;j++)
			if ( mount[i][j]>=mount[i-1][j])
				if (mount[i][j]>=mount[i+1][j])
					if (mount[i][j]>=mount[i][j-1])
						if (mount[i][j]>=mount[i][j+1])
						{
							pr[s]=i-1;
							pc[s]=j-1;
							s++;
						}
	for (i=0;i<s;i++)
		for (j=s-1;j>=i+1;j--)
			if (pr[j-1]>pr[j])
			{
				temp=pr[j];
				pr[j]=pr[j-1];
				pr[j-1]=temp;

				temp=pc[j];
				pc[j]=pc[j-1];
				pc[j-1]=temp;
			}
	for (i=0;i<s;i++)
		if (pr[i]==pr[i+1])
			if (pc[i]>pc[i+1])
			{
				temp=pc[j];
				pc[j]=pc[j+1];
				pc[j+1]=temp;
			}
	for (i=0;i<s;i++)
		cout << pr[i] <<" "<< pc[i] << endl;
	return 0;
}