semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int m,n,i,j,a[23][23],b[23][23];
	cin>>m>>n;
	for(i=0;i<23;i++)
	{
		for(j=0;j<23;j++)
		{
			b[i][j]=0;
		}
	}
	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+1;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][j+1])&&(a[i][j]>=a[i][j-1])&&(a[i][j]>=a[i+1][j])&&(a[i][j]>=a[i-1][j]))
			{
				b[i][j]=1;
			}
		}
	}
	for(i=0;i<23;i++)
	{
		for(j=0;j<23;j++)
		{
			if(b[i][j]==1)
			{
				cout<<i-1<<" "<<j-1<<endl;
			}
		}
	}
	return 0;
}
int main(){
	int n,m,sz[20][20],row,col;
	scanf("%d %d",&m,&n);
	for(row=0;row<m;row++){
		for(col=0;col<n;col++){
			scanf("%d",&sz[row][col]);
		}
	}
	if(sz[0][0]>=sz[0][1]&&sz[0][0]>=sz[1][0])
		printf("%d %d\n",0,0);
	for(col=1;col<n-1;col++){
		if(sz[0][col]>=sz[0][col-1]&&sz[0][col]>=sz[1][col]&&sz[0][col]>=sz[0][col+1])
			printf("%d %d\n",0,col);
	}
	if(sz[0][n-1]>=sz[0][n-2]&&sz[0][n-1]>=sz[1][n-1])
		printf("%d %d\n",0,n-1);
	for(row=1;row<m-1;row++){
		if(sz[row][0]>=sz[row][1]&&sz[row][0]>=sz[row-1][0]&&sz[row][0]>=sz[row+1][0])
			printf("%d %d\n",row,0);
		for(col=1;col<n-1;col++){
		if(sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row+1][col]&&sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row-1][col])
			printf("%d %d\n",row,col);
		}
		if(sz[row][n-1]>=sz[row][n-2]&&sz[row][n-1]>=sz[row+1][n-1]&&sz[row][n-1]>=sz[row-1][n-1])
			printf("%d %d\n",row,n-1);
	}
	if(sz[m-1][0]>=sz[m-1][1]&&sz[m-1][0]>=sz[m-2][0])
		printf("%d %d\n",m-1,0);
	for(col=1;col<n-1;col++){
		if(sz[m-1][col]>=sz[m-1][col-1]&&sz[m-1][col]>=sz[m-2][col]&&sz[m-1][col]>=sz[m-1][col+1])
			printf("%d %d\n",m-1,col);
	}
	if(sz[m-1][n-1]>=sz[m-1][n-2]&&sz[m-1][n-1]>=sz[m-2][n-1])
		printf("%d %d",m-1,n-1);
	return 0;
}
int main(){
	int m,n;
	scanf("%d %d",&m,&n);
	int s[200][200];
	int i,r,j;
	for(i=0;i<m;i++){
		for(r=0;r<n-1;r++){
			scanf("%d ",&s[i][r]);
		}
		if(r==n-1){
			scanf("%d",&s[i][r]);
		}
	}
	int z,x,c,v,p;
	i=0;
	if(i==0){
		r=0;
		if(r==0){
			x=s[i+1][r];
			v=s[i][r+1];
        
			if((s[i][r]>=x)&&(s[i][r]>=v)){
				printf("%d %d\n",i,r);
			}
		}
		for(r=1;r<n-1;r++){
             x=s[i+1][r];
			 c=s[i][r-1];
			v=s[i][r+1];
			if((s[i][r]>=x)&&(s[i][r]>=v)&&(s[i][r]>=c)){
				printf("%d %d\n",i,r);
			}
		}
		if(r==n-1){
			 x=s[i+1][r];
			 c=s[i][r-1];
			 	if((s[i][r]>=x)&&(s[i][r]>=c)){
				printf("%d %d\n",i,r);
			}
		}
	}
	for(i=1;i<m-1;i++){
		r=0;
		if(r==0){
			z=s[i-1][r];
			x=s[i+1][r];
			v=s[i][r+1];
			if((s[i][r]>=z)&&(s[i][r]>=x)&&(s[i][r]>=v)){
				printf("%d %d\n",i,r);
			}
		}
		for(r=1;r<n-1;r++){
		    z=s[i-1][r];
			x=s[i+1][r];
			c=s[i][r-1];
			v=s[i][r+1];
			if((s[i][r]>=z)&&(s[i][r]>=x)&&(s[i][r]>=v)&&(s[i][r]>=c)){
				printf("%d %d\n",i,r);
			}
		}
       if(r==n-1){
           z=s[i-1][r];
			x=s[i+1][r];
			c=s[i][r-1];
			if((s[i][r]>=z)&&(s[i][r]>=x)&&(s[i][r]>=c)){
				printf("%d %d\n",i,r);
			}
		}
	   }
	if(i==m-1){
		r=0;
		if(r==0){
			z=s[i-1][r];
			v=s[i][r+1];
			if((s[i][r]>=z)&&(s[i][r]>=v)){
				printf("%d %d\n",i,r);
			}
		}
		for(r=1;r<n-1;r++){
		    z=s[i-1][r];
			c=s[i][r-1];
			v=s[i][r+1];
			if((s[i][r]>=z)&&(s[i][r]>=v)&&(s[i][r]>=c)){
				printf("%d %d\n",i,r);
			}
		}
       if(r==n-1){
           z=s[i-1][r];
			c=s[i][r-1];
			if((s[i][r]>=z)&&(s[i][r]>=c)){
				printf("%d %d\n",i,r);
			}
		}
	   }
	return 0;
}
int main()
{
    int m=0,n=0,i=0,j=0,a[30][30];
    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;
    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-1][j])&&(a[i][j]>=a[i+1][j])&&(a[i][j]>=a[i][j+1])&&(a[i][j]>=a[i][j-1]))
          cout<<i<<" "<<j<<endl;
       }
       if((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;
}
/*
 * d.cpp
 *
 *  Created on: 2013-12-13
 *      Author: de
 */
int main(){
	int m,n,i,j;
	cin>>m>>n;
	int data[m][n];
	for(i=0;i<m;i++)
		for(j=0;j<n;j++)
			cin>>data[i][j];
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(i==0){
			   if(j==0){
				   if(data[i][j]>=data[i][j+1]&&data[i][j]>=data[i+1][j])
					   {cout<<i<<" "<<j<<endl;continue;}
			}
			   if(j==n-1){
				   if(data[i][j]>=data[i][j-1]&&data[i][j]>=data[i+1][j])
				   					   {cout<<i<<" "<<j<<endl;continue;}
			   }
			   else{
				   if(data[i][j]>=data[i][j-1]&&data[i][j]>=data[i][j+1]&&data[i][j]>=data[i+1][j])
					   {cout<<i<<" "<<j<<endl;continue;}
			   }
			}
			if(i==m-1){
				if(j==0){
								   if(data[i][j]>=data[i][j+1]&&data[i][i]>=data[i-1][j])
									   {cout<<i<<" "<<j<<endl;continue;}
							}
							   if(j==n-1){
								   if(data[i][j]>=data[i][j-1]&&data[i][j]>=data[i-1][j])
								   					   {cout<<i<<" "<<j<<endl;continue;}
							   }
							   else{
								   if(data[i][j]>=data[i][j-1]&&data[i][j]>=data[i][j+1]&&data[i][j]>=data[i-1][j])
									   {cout<<i<<" "<<j<<endl;continue;}
							   }
			}
			else{
				if(j==0){
					if(data[i][j]>=data[i-1][j]&&data[i][j]>=data[i+1][j]&&data[i][j]>=data[i][j+1])
					{cout<<i<<" "<<j<<endl;continue;}
				}
				if(j==n-1){
					if(data[i][j]>=data[i-1][j]&&data[i][j]>=data[i+1][j]&&data[i][j]>=data[i][j-1])
										{cout<<i<<" "<<j<<endl;continue;}
				}
				else {if(data[i][j]>=data[i-1][j]&&data[i][j]>=data[i+1][j]&&data[i][j]>=data[i][j-1]&&data[i][j]>=data[i][j+1])
					{cout<<i<<" "<<j<<endl;continue;}
			}
			}
		}
	}
	return 0;
}
int main()
{
	int m,n,i,j;
	int num[22][22];
	cin>>m>>n;
	for(i=0;i<22;i++)
	{
		for(j=0;j<22;j++)
		{
			num[i][j]=0;
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>num[i][j];
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if((num[i][j]>=num[i-1][j])&&(num[i][j]>=num[i+1][j])&&(num[i][j]>=num[i][j-1])&&(num[i][j]>=num[i][j+1]))
			{
				cout<<i-1<<' '<<j-1<<endl;
			}
		}
	}
	return 0;
}
int main()
{
    int m,n,a[20][20],i,j;
    scanf("%d%d",&m,&n);
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {scanf("%d",&a[i][j]);}
    }
    if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0]){printf("0 0\n");}
    for(j=1;j<n-1;j++)
    {
        if(a[0][j]>=a[0][j-1]&&a[0][j]>=a[0][j+1]&&a[0][j]>=a[1][j]){printf("0 %d\n",j);}
    }
    if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1]){printf("0 %d\n",n-1);}
    for(i=1;i<m-1;i++)
    {
        if(a[i][0]>=a[i][1]&&a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0]){printf("%d 0\n",i);}
        for(j=1;j<n-1;j++)
        {
        if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i-1][j]){printf("%d %d\n",i,j);}
        }
        if(a[i][n-1]>=a[i][n-2]&&a[i][n-1]>=a[i-1][n-1]&&a[i][n-1]>=a[i+1][n-1]){printf("%d %d\n",i,n-1);}
    }
    if(a[m-1][0]>=a[m-2][0]&&a[m-1][0]>=a[m-1][1]){printf("%d %d\n",m-1,0);}
    for(j=1;j<n-1;j++)
    {
        if(a[m-1][j]>=a[m-1][j-1]&&a[m-1][j]>=a[m-1][j+1]&&a[m-1][j]>=a[m-2][j]){printf("%d %d\n",m-1,j);}
    }
    if(a[m-1][n-1]>=a[m-2][n-1]&&a[m-1][n-1]>=a[m-1][n-2]){printf("%d %d\n",m-1,n-1);}
    return 0;
}
int main(){
    int n,m,i,j;
    int map[100][100];
    scanf("%d%d",&n,&m);
   for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      scanf("%d",&map[i][j]);
   for(i=1;i<=n;i++)map[i][0]=map[i][m+1]=0;
   for(i=1;i<=m;i++)map[0][i]=map[n+1][i]=0;
   int f=0;
   for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      if(map[i][j]>=map[i-1][j]&&map[i][j]>=map[i][j-1]&&map[i][j]>=map[i+1][j]&&map[i][j]>=map[i][j+1]){
                      if(f)printf("\n");
                      printf("%d %d",i-1,j-1);f=1;
                      }
       return 0;
    }
int a[22][22],n,m;
int main()
{
	int i,j;
	cin>>n>>m;
	for(i=0;i<=n+1;i++)
	for(j=0;j<=m+1;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][j]>=a[i-1][j] &&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1]) cout<<i-1<<" "<<j-1<<endl;
		}
	}
	return 0;
}
int main()
{
	int m,n,a[22][22]={0};
	cin>>m>>n;
	for(int i=1;i<m+1;i++)
	{
		for(int j=1;j<n+1;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][j-1]&&a[i][j]>=a[i+1][j])
				cout<<i-1<<" "<<j-1<<endl;
		}
	}
	return 0;
}
int a[100][100];

int main()
{
	int m, n;
	int i, j;
	int lenth[150];
	int width[150];
	int count = 0;

	cin >> m >> n;

	memset(a, 0, sizeof(a));

	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 ++)
	{
		int tag = 1;

		if(a[i][j] < a[i + 1][j])	tag = 0;
		if(a[i][j] < a[i - 1][j])	tag = 0;
		if(a[i][j] < a[i][j + 1])	tag = 0;
		if(a[i][j] < a[i][j - 1])	tag = 0;

		if(tag == 1)
		{
			lenth[count] = i;
			width[count] = j;
			count ++;
		}
	}

	for(i = 0; i < count; i ++)
		cout << lenth[i] - 1 << ' ' << width[i] - 1 << endl;

	
}
int main()
{
	int m,n,i,j,h[30][30];
	scanf("%d%d",&m,&n);
	for(j=0;j<=(n+1);j++)
	{
		h[0][j]=-1;
		h[m+1][j]=-1;
	}
	for(i=0;i<=(m+1);i++)
	{
		h[i][0]=-1;
		h[i][n+1]=-1;
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&h[i][j]);
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;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]))
			{
				printf("%d %d\n",i-1,j-1);
			}
		}
	}
	return 0;
}
int main()
{
	int a[20][20],m,n,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==0&&j==0&&a[0][0]>=a[1][0]&&a[0][0]>=a[0][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][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(i==0&&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)&&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==(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((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;
}
int sz[22][22];
int main(){
	int m,n,i,j;
	
	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<=n+1;i++){
		sz[0][i]=sz[m+1][i]=0;
		sz[i][0]=sz[i][n+1]=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])){
				i--;j--;
				printf("%d %d\n",i,j);
				i++;j++;
			}
		}
	}
	return 0;
}
int main()
{
	int e,i,j,n,m,k=0,sz[len+2][len+2],x[len],y[len];
	scanf("%d %d",&m,&n);
	for(j=1;j<m+1;j++)
	{
		for(i=1;i<n+1;i++)
		{
			scanf("%d",&sz[j][i]);
		}
	}
		for(j=0;j<m+2;j++)
		{
			for(i=0;i<n+2;i++)
			{
				sz[0][i]=0;
				sz[j][0]=0;
				sz[m+1][i]=0;
				sz[j][n+1]=0;
			}
		}
		for(j=1;j<m+1;j++)
		{

			
			
			
			
			
			
			
			
			for(i=1;i<n+1;i++)
			{
				if((sz[j][i]>=sz[j][i+1])&&(sz[j][i]>=sz[j][i-1])&&(sz[j][i]>=sz[j+1][i])&&(sz[j][i]>=sz[j-1][i]))
				{
					x[k]=j-1;
					y[k]=i-1;
					k++;
				}

			
			
			}
		}
		
		for(i=0;i<k;i++)
		{
			printf("%d %d\n",x[i],y[i]);
		}
		return 0;
}
int main(){
    int m,n;
    scanf("%d %d",&m,&n);
    int a[30][30]={0};
    int b[400][2]={0};
    int i,j,k=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+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++){
        for(j=i;j<k;j++){
            if(b[i][0]>=b[j][0]){
                int tmp1,tmp2;
                tmp1=b[i][0];
                tmp2=b[i][1];
                b[i][0]=b[j][0];
                b[i][1]=b[j][1];
                b[j][0]=tmp1;
                b[j][1]=tmp2;
            }
        }
    }
    for(i=0;i<k;i++){
        for(j=i;j<k;j++){
            if(b[i][0]==b[j][0]){
            if(b[i][1]>=b[j][1]){
                int tmp1,tmp2;
                tmp1=b[i][0];
                tmp2=b[i][1];
                b[i][0]=b[j][0];
                b[i][1]=b[j][1];
                b[j][0]=tmp1;
                b[j][1]=tmp2;
            }
            }
        }
    }
    for(i=0;i<k;i++){
        printf("%d %d\n",b[i][0]-1,b[i][1]-1);
    }
    return 0;
}
int main()
{
   int m,n,a,b,i,j;
   int h[22][22];
   scanf("%d%d",&m,&n);
   for(a=0;a<22;a++)
   {for(b=0;b<22;b++)
      h[a][b]=0;
                    }
      for(i=1;i<m+1;i++)
      {for(j=1;j<n+1;j++)
      {scanf("%d",&h[i][j]);}}
      for(i=1;i<m+1;i++){
                         for(j=1;j<n+1;j++)
                         {if(h[i][j]>=h[i-1][j]&&h[i][j]>=h[i][j-1]&&h[i][j]>=h[i+1][j]&&h[i][j]>=h[i][j+1])
                         printf("%d %d\n",i-1,j-1);}}
                         return 0;
                         }
int main()
{
	int m, n, i, j;
	int sum = 0;
	int cell[22][22]={0};

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

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

	return 0;
}
int main(){
	int m,n,row,col;
	int sz[20][20];

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

	for(row=0;row<m;row++){
		for(col=0;col<n;col++){
			if(row==0){
				if(col==0&&sz[0][0]>=sz[0][1]&&sz[0][0]>=sz[1][0]){
					printf("%d %d\n",row,col);
				}else if(col==n-1&&sz[0][n-1]>=sz[0][n-2]&&sz[0][n-1]>=sz[1][n-1]){
					printf("%d %d\n",row,col);
				}else if(sz[0][col]>=sz[0][col-1]&&sz[0][col]>=sz[0][col+1]&&sz[0][col]>=sz[1][col]){
					printf("%d %d\n",row,col);
				}
			}else if(col==0){
				if(row==n-1&&sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row-1][col]){
					printf("%d %d\n",row,col);
				}else if(sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row+1][col]){
					printf("%d %d\n",row,col);
				}
			}else if(row==m-1){
				if(col==n-1&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row-1][col]){
					printf("%d %d\n",row,col);
				}else if(sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row-1][col]){
					printf("%d %d\n",row,col);
				}
			}else if(col==n-1&&sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row+1][col]){
				printf("%d %d\n",row,col);
			}else if(sz[row][col]>=sz[row][col-1]&&sz[row][col]>=sz[row][col+1]&&sz[row][col]>=sz[row-1][col]&&sz[row][col]>=sz[row+1][col]){
					printf("%d %d\n",row,col);
			}

		}
	}


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

}
int main()
{
	int n,m,a,b;
	scanf("%d%d",&n,&m);
	int sz[1000][1000];
	for(a=1;a<n+1;a++)
	{
		for(b=1;b<m+1;b++)
		{
			scanf("%d",&(sz[a][b]));
		}
	}

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

for(i=0;i<=m-1;i++)
{
                   for(j=0;j<=n-1;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);continue;}
                                      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);continue;}
                                      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);continue;}
                                      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);continue;}
                                      
                                      if(i==0&&j!=n-1&&j!=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);continue;}
                                     if(i==m-1&&j!=n-1&&j!=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);continue;}
                                      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);continue;}
                                      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);continue;}
                                      
                                      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]&&a[i][j]>=a[i][j-1])
                                       {printf("%d %d\n",i,j);continue;}
                   }
}
                                      
  
   return 0;
}
int main()
{
    int m,n,i,j;
    int c[100][100];
    scanf("%d %d",&m,&n);
    
        
    for(i=1;i<=m;i++)
                    {
                                   for(j=1;j<=n;j++)
                                   {  
                                   scanf("%d",&(c[i][j]));
                                   }
                     }
                     if((i==0)||(j==0)||(i==m+1)||(j==n+1))
                     {
							c[i][j]=0;
					}
     for(i=1;i<=m;i++)
	 {
			for(j=1;j<=n;j++)
			{                
                    
                    
						if((c[i][j]>=c[i-1][j])&&(c[i][j]>=c[i][j-1])&&(c[i][j]>=c[i+1][j])&&(c[i][j]>=c[i][j+1]))
						{
						  printf("%d %d\n",i-1,j-1);
					    }
					
		    }
     }
   
	          
    
    return 0;
}
int h[21][21];
int main()
{
	int i=1,j=1,m=0,n=0;
  cin>>m>>n;
  for (i=1;i<=m;i++)
  {
     for (j=1;j<=n;j++)
	 {
		 cin>>h[i][j];
	 }
  }
  i=j=1;
  for (i=1;i<=m;i++)
  {
     for (j=1;j<=n;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]))
			 cout<<i-1<<" "<<j-1<<endl;
	 }
  }
  return 0;
}
/*????*/
void judge(int a[][20],int m,int n)
{
   int i=0,j=0;
   if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])  printf("%d %d\n",i,j);
   for(j=1,i=0;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]) printf("%d %d\n",i,j);
   }
   j=n-1;
   if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j]) printf("%d %d\n",i,j);
   for(i=1;i<m-1;i++)
   {
      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);
      for(j=1;j<n-1;j++)
         if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j]) printf("%d %d\n",i,j);
      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);
   } 
   j=0;
   i=m-1;
   if(a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]) printf("%d %d\n",i,j);
   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]) printf("%d %d\n",i,j);
   
   j=n-1;
   if(a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j]) printf("%d %d\n",i,j);
}
void main()
{
   int m,n,i,j;
   scanf("%d%d",&m,&n);
   int a[20][20];
   
   for(i=0;i<m;i++)
   {
      for(j=0;j<n;j++)
          scanf("%d",&a[i][j]);
   }
   
   judge(a,m,n);
   
}
void main()
{
	int m,n,a[300][300],i,j,t;
	scanf("%d %d\n",&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++)
	scanf("%d",&a[i][j]);
	}
	for(i=1;i<=m;i++)
	{
	for(j=1;j<=n;j++)
	{
	t=0;
	if(a[i-1][j]<=a[i][j]) t++;
	if(a[i+1][j]<=a[i][j]) t++;
	if(a[i][j-1]<=a[i][j]) t++;
	if(a[i][j+1]<=a[i][j]) t++;
	if(t==4) printf("%d %d\n",i-1,j-1);
	}
	}
}
int main()
{
	int m,n;
	int i,j;
	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]);
		}
	}
	for(i=0;i<m;i++)
	{
		if(i==0)
		{
			if(a[0][0]>=a[0][1]&&a[0][0]>=a[1][0])
				printf("0 0\n");
			for(j=1;j<n-1;j++)
			{
               if(a[0][j]>=a[0][j-1]&&a[0][j]>=a[0][j+1]&&a[0][j]>=a[1][j])
			   {
				   printf("0 %d\n",j);
			   }
			}
			if(a[0][n-1]>=a[0][n-2]&&a[0][n-1]>=a[1][n-1])
			{
				printf("0 %d\n",n-1);
			}
		}
		if(i>0&&i<m-1)
		{
			for(i=1;i<m-1;i++)
			{
				if(a[i][0]>=a[i-1][0]&&a[i][0]>=a[i+1][0]&&a[i][0]>=a[i][1])
				{
					printf("%d 0\n",i);
				}
				for(j=1;j<n-1;j++)
				{
					if(a[i][j]>=a[i-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);
					}
				}
				if(a[i][n-1]>=a[i-1][n-1]&&a[i][n-1]>=a[i+1][n-1]&&a[i][n-1]>=a[i][n-2])
				{
					printf("%d %d\n",i,n-1);
				}
			}
		}
		if(i==m-1)
		{
			if(a[m-1][0]>=a[m-1][1]&&a[m-1][0]>=a[m-2][0])
				printf("%d 0\n",m-1);
			for(j=1;j<n-1;j++)
			{
               if(a[m-1][j]>=a[m-1][j-1]&&a[m-1][j]>=a[m-1][j+1]&&a[m-1][j]>=a[m-2][j])
			   {
				   printf("%d %d\n",m-1,j);
			   }
			}
			if(a[m-1][n-1]>=a[m-1][n-2]&&a[m-1][n-1]>=a[m-2][n-1])
			{
				printf("%d %d\n",m-1,n-1);
			}
		}
	}
	return 0;
}