semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(int argc, char* argv[])
{
    int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int n,y,m1,m2;
	scanf("%d",&n);
	int i;
	int j,count=0;
	for(i=0;i<n;i++)
	{
		count=0;
		days[2]=28;
		scanf("%d%d%d",&y,&m1,&m2);
		if((y%4==0)&&(y%100!=0)||(y%400==0))
		{
			days[2]++;
		}
		if(m1<m2)
		{
			for(j=m1;j<m2;j++)
			{
				count+=days[j];
			}
		}
		else 
		{
			for(j=m2;j<m1;j++)
			{
				count+=days[j];
			}
		}
		if(count%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	
	return 0;
}
int main(){
	int n,i,nian,y[2],q[2]={0,0},k,a,e;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&nian,&y[0],&y[1]);
		for(k=0;k<2;k++){
			for(e=1;e<y[k];e++){
		if(e==1||e==3||e==5||e==7||e==8||e==10||e==12){
              q[k]+=3;
		}else if(e==4||e==6||e==9||e==11){
			q[k]+=2;
		}else if(e==2){
			if(nian%400==0||(nian%4==0&&nian%100!=0)){
				q[k]+=1;
			}else{
				q[k]+=0;
			}
		}
			}
		}
	    a=(q[1]-q[0])%7; 
		q[0]=0;
q[1]=0;
		if(a==0){
			printf("YES\n");

		}else{
			printf("NO\n");

		}
		
	}

	return 0;
}
int main()
{
	int n, year, mon1, mon2, sum, c, d;
	int Lyear[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int Oyear[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		sum = 0;
		cin >> year >> mon1 >> mon2;
		c = (mon1 > mon2 ? mon2 : mon1);
		d = (mon1 > mon2 ? mon1 : mon2);
		if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
		{
			for (int j = c; j < d; j++)
			{
				sum = sum + Lyear[j - 1];
			}
		}
		else
		{
			for (int k = c; k < d; k++)
			{
				sum = sum + Oyear[k - 1];
			}
		}
		
		if (sum % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;

}
//????
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&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])//?????
				cout<<i<<' '<<j<<endl;
			if (i==0&&j==n-1&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i+1][j])				
				cout<<i<<' '<<j<<endl;
			if (i==m-1&&j==0&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])
				cout<<i<<' '<<j<<endl;
			if (i==m-1&&j==n-1&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
				cout<<i<<' '<<j<<endl;
			if (i==0&&j>=1&&j<=n-2&&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;
			if (i==m-1&&j>=1&&j<=n-2&&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;
			if (j==0&&i>=1&&i<=m-2&&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 (j==n-1&&i>=1&&i<=m-2&&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 (i>=1&&i<=m-2&&j>=1&&j<=n-2&&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;
		}
	}
		return 0;
}
int main()
{
int a[22][22]={0};
int m,n;
scanf("%d %d",&m,&n);
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])
printf("%d %d\n",i-1,j-1);
}
/*
 * 4.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main(){
	int m,n;
	cin>>m>>n;
	const int mm=m+2,nn=n+2;
	int a[mm][nn],i,j;
	for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
			cin>>a[i][j];
	for(i=0;i<=m+1;i++){
		a[i][n+1]=0;
		a[i][0]=0;
	}
	for(j=0;j<=n+1;j++){
		a[0][j]=0;
		a[m+1][j]=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])
				continue;
			cout<<i-1<<' '<<j-1<<endl;
		}
	return 0;
}
int main()
{
    int m,n;
    cin>>m>>n;
    int a[m+2][n+2];
    for(int i=1;i<=m;i++)
    {
            for(int j=1;j<=n;j++)
            cin>>a[i][j];
    }
    for(int i=0;i<m+2;i++)
    {
    a[i][0]=0;
    a[i][n+1]=0;
    }
    for(int i=0;i<n+2;i++)
    {
            a[0][i]=0;
            a[m+1][i]=0;
    }
    for(int i=1;i<=m;i++)
    {
            for(int j=1;j<=n;j++)
            {
            if(a[i][j]>=a[i-1][j]&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i][j+1])
            cout<<i-1<<' '<<j-1<<endl;
            }                    
    }
}
int main()
{
    int m,n;//????????
	cin>>m>>n;//?????
	int i,j;//????
	int a[20][20];//????????
	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++)//?2?m-1???
	{
		if(a[i][0]>=a[i-1][0]&&a[i][0]>=a[i][1]&&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][j-1]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i+1][j])
				cout<<i<<" "<<j<<endl;
		if(a[i][n-1]>=a[i-1][n-1]&&a[i][n-1]>=a[i][n-2]&&a[i][n-1]>=a[i+1][n-1])
			cout<<i<<" "<<n-1<<endl;
	}

	if(a[m-1][0]>=a[m-2][0]&&a[m-1][0]>=a[m-1][1])//?m???
		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-2][i]&&a[m-1][i]>=a[m-1][i+1])
			cout<<m-1<<" "<<i<<endl;
	if(a[m-1][n-1]>=a[m-2][n-1]&&a[m-1][n-1]>=a[m-1][n-2])
		cout<<m-1<<" "<<n-1<<endl;

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

	int h[ 22 ][ 22 ];
	int x[ 400 ], y[ 400 ];
	memset( h, 0, sizeof( h ) );
	cin >> m >> n;
	for ( i = 1; i < m + 1; i++ )
		for ( j = 1; j < n + 1; j++ )
			cin >> 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 - 1][ j ]&&
				h[i][j] >= h[i][j+1] &&
				h[ i ][ j ] >= h[ i][ j - 1 ] )
			{
			cout << i -1 << " " << j - 1 << endl;
			}
		}


}
int m,n,a[25][25];
void f(int x,int y)
{
	if(x<m && y<n)
	{
		int d=0;
		if((x-1>=0 && a[x][y]>=a[x-1][y])||x-1<0)
			d++;
		if((x+1<m && a[x][y]>=a[x+1][y]) || x+1>=m)
			d++;
		if((y-1>=0 && a[x][y]>=a[x][y-1]) || y-1<0)
			d++;
		if((y+1<n && a[x][y]>=a[x][y+1]) || y+1>=n)
			d++;
		if(d==4)
			cout << x <<" " << y << endl;
		if(y+1<n){
			f(x,y+1);}
		else{
			f(x+1,0);}
	}
}
int main()
{
	cin>> m >> n;
	int i=0,j=0;
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			cin >> a[i][j];}}
	f(0,0);
	return 0;
}
int main()
{
	int m,n,a[40][40];
	cin>>m>>n;
	for(int i=0;i<=m+1;i++)
		for(int j=0;j<=n+1;j++)
			a[i][j]=0;
	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+1;i++)
		for(int j=1;j<n+1;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;
	return 0;
}
int main(){
	int m,n,i,j;
	int s[27][27];
    scanf("%d%d",&m,&n);
	for(i=0;i<m+2;i++){
		s[i][0]=0;
	}
for(i=0;i<m+2;i++){
		s[i][n+1]=0;
	}
for(i=0;i<n+2;i++){
		s[0][i]=0;
	}
for(i=0;i<n+2;i++){
		s[m+1][i]=0;
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
		   if(s[i][j]>=s[i+1][j]&&s[i][j]>=s[i-1][j]&&s[i][j]>=s[i][j-1]&&s[i][j]>=s[i][j+1])
			   printf("%d %d\n",i-1,j-1);
		}
	}
return 0;
}
int main(int argc, char* argv[])
{
	int m,n,sz[22][22],i,j,p,q;
	scanf("%d%d",&m,&n);
	for(i=0;i<m+2;i++)
	{
		for(j=0;j<n+2;j++)
		{
			if(i==0||i==m+1||j==0||j==n+1)
			{
				sz[i][j]=0;
			}
			else
			{
			    scanf("%d",&sz[i][j]);
			}
		}
	}
    for(i=1;i<m+1;i++)
	{
		for(j=1;j<n+1;j++)
		{
			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])
			{
				printf("%d %d\n",i-1,j-1);
			}
		}
	}
               
	return 0;
}
int main()
{
	int m, n;
	cin >> m >> n;
	int mount[22][22];
	int 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)
				mount[i][j] = 0;
			else
				cin >> mount[i][j];
		}
	}
	for(i = 1; i <= m; i++)
	{
		for(j = 1; j <= n; j++)
		{
			if(mount[i][j] >= mount[i - 1][j] && mount[i][j] >= mount[i + 1][j]
				&& mount[i][j] >= mount[i][j + 1] && mount[i][j] >= mount[i][j - 1])
				cout << i - 1 << " " << j - 1 << endl;
		}
	}
	return 0;
}
int main()
{
	int m,n;
	cin>>m>>n;
	int i,j,a[22][22]={0},b[21][21]={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[i-1][j-1]=2;

		}
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			if(b[i][j]==2)cout<<i<<" "<<j<<endl;
		}
	}


	



	return 0;
}
int main()
{
    int a[20][20];
    int m, n;
    int i, j;
    cin>>m;
    cin>>n;
    for(j=0;j<m;j++)
    {
        for(i=0;i<n;i++)
        {
            cin>>a[j][i];
        }
    }
    for(j=0;j<m;j++)
    {
        if(j==0)
        {
            if(a[0][0]>=a[1][0]&&a[0][0]>=a[0][1])
                cout<<j<<" 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<<j<<" "<<i<<endl;
            }
            if(a[0][n-1]>=a[1][n-1]&&a[0][n-1]>=a[0][n-2])
                cout<<j<<" "<<n-1<<endl;
            continue;
        }
        if(j>0&&j<m-1)
        {
            if(a[j][0]>=a[j+1][0]&&a[j][0]>=a[j][1]&&a[j][0]>=a[j-1][0])
                cout<<j<<" 0"<<endl;
            for(i=1;i<n-1;i++)
            {
                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;
            }
            if(a[j][n-1]>=a[j+1][n-1]&&a[j][n-1]>=a[j-1][n-1]&&a[j][n-1]>=a[j][n-2])
                cout<<j<<" "<<n-1<<endl;
            continue;
        }
        if(j==m-1)
        {
            if(a[j][0]>=a[j][1]&&a[j][0]>=a[j-1][0])
                cout<<j<<" 0"<<endl;
            for(i=1;i<n-1;i++)
            {
                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;
            }
            if(a[j][n-1]>=a[j-1][n-1]&&a[j][n-1]>=a[j][n-2])
                cout<<j<<" "<<n-1<<endl;
            continue;
        }             
    }
	return 0;
}
int main()
{
    int m,n;
    scanf("%d %d",&m,&n);
    int hei[m][n];//??
    int top[m][n];//?????
    
    int i,j;
    for(i=0;i<m;i=i+1)//????
    {
        for(j=0;j<n;j=j+1)
        {
            scanf("%d",&(hei[i][j]));
            top[i][j]=1;
        }
    }
    
    for(i=0;i<m;i=i+1)//???????
    {
        for(j=0;j<n;j=j+1)
        {
            if(i-1>=0 && hei[i-1][j]>hei[i][j]){top[i][j]=0;}
            else if(i+1<=m-1 && hei[i+1][j]>hei[i][j]){top[i][j]=0;}
            else if(j+1<=n-1 && hei[i][j+1]>hei[i][j]){top[i][j]=0;}
            else if(j-1>=0 && hei[i][j-1]>hei[i][j]){top[i][j]=0;}
        }
    }
    
    for(i=0;i<m;i=i+1)//???????????
    {
        for(j=0;j<n;j=j+1)
        {
            if(top[i][j]==1){printf("%d %d\n",i,j);}
        }
    }
    
    return(0);
    
}
void main()
{
	int a[21][21]={0};
	int i,j,m,n;
	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)
			{
				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)
			{
				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(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((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);
			}
		}
	}
}
int main()
{
	int m,n,i,j,a[100][100],x[100],y[100],p=0,k;
	cin>>m>>n;
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(j=0;j<=n+1;j++)
	{
		a[0][j]=a[1][j];
	}
	for(j=0;j<=n+1;j++)
	{
		a[m+1][j]=a[m][j];
	}
	for(i=0;i<=m+1;i++)
	{
		a[i][0]=a[i][1];
	}
	for(i=0;i<=m+1;i++)
	{
		a[i][n+1]=a[i][n];
	}
	/*for(i=0;i<=m+1;i++)
	{
		for(j=0;j<=n+1;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}*/
	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])
			{
				x[p]=i;
				y[p]=j;
				p++;
			}
		}
	}
	for(j=0;j<=p-2;j++)
	{
		for(i=0;i<=p-2-j;i++)
		{
			if(x[i]>x[i+1]||x[i]==x[i+1]&&y[i]>y[i+1])
			{
				k=x[i];
				x[i]=x[i+1];
				x[i+1]=k;
				k=y[i];
				y[i]=y[i+1];
				y[i+1]=k;

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


void main()
{
	int m,n,i,j,a[20][20]={0};
	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++)
	{top(i,j,m,n,a);
	}
	}
}
int main(){
	int array[30][20],i,j,m,n;
	scanf("%d%d",&m,&n);
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d",&array[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(i==00&&j==0){
				if(array[i][j]>=array[i+1][j]&&array[i][j]>=array[i][j+1]){
					printf("0 0\n");
				}
			}
			if(i==0&&j!=0&&j!=n-1){
				if(array[i][j]>=array[i][j-1]&&array[i][j]>=array[i][j+1]&&array[i][j]>=array[i+1][j]){
					printf("%d %d\n",i,j);
				}
			}
			if(i==0&&j==n-1){
				if(array[i][j]>=array[i][j-1]&&array[i][j]>=array[i+1][j]){
					printf("%d %d\n",i,j);
				}
			}
			if(i!=0&&i!=m-1&&j==0){
				if(array[i][j]>=array[i-1][j]&&array[i][j]>=array[i+1][j]&&array[i][j]>=array[i][j+1]){
					printf("%d %d\n",i,j);
				}
			}
			if(i!=0&&j!=0&&i!=m-1&&j!=n-1){
				if(array[i][j]>=array[i-1][j]&&array[i][j]>=array[i+1][j]&&array[i][j]>=array[i][j-1]&&array[i][j]>=array[i][j+1]){
					printf("%d %d\n",i,j);
				}
			}
			if(i!=0&&i!=m-1&&j==n-1){
				if(array[i][j]>=array[i][j-1]&&array[i][j]>=array[i+1][j]&&array[i][j]>=array[i-1][j]){
					printf("%d %d\n",i,j);
				}
			}
			if(i==m-1&&j==0){
				if(array[i][j]>=array[i-1][j]&&array[i][j]>=array[i][j+1]){
					printf("%d %d\n",i,j);
				}
			}
			if(i==m-1&&j!=0&&j!=n-1){
				if(array[i][j]>=array[i-1][j]&&array[i][j]>=array[i][j-1]&&array[i][j]>=array[i][j+1]){
					printf("%d %d\n",i,j);
				}
			}
			if(i==m-1&&j==n-1){
				if(array[i][j]>=array[i-1][j]&&array[i][j]>=array[i][j-1]){
					printf("%d %d",i,j);
				}
			}
		}
	}
	return 0;
}
main()
{
	int m,n,i,j,moun[30][30]={0};
	scanf("%d%d",&m,&n);
	for(i=1;i<m+1;i++)
		for(j=1;j<n+1;j++)
			scanf("%d",*(moun+i)+j);
	for(i=1;i<m+1;i++)
		for(j=1;j<n+1;j++)
			if(
				*(*(moun+i)+j)>=*(*(moun+i-1)+j)
				&&*(*(moun+i)+j)>=*(*(moun+i+1)+j)
				&&*(*(moun+i)+j)>=*(*(moun+i)+j-1)
				&&*(*(moun+i)+j)>=*(*(moun+i)+j+1)
              )
			  printf("%d %d\n",i-1,j-1);
	return 0;
}
int main() {
   int m,n,i,j;
   int sz[20][20];
   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;i++) {
       for(j=0;j<n;j++) {
            if(i>0&&i<m-1&&j>0&&j<n-1&&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]) {
                    printf("%d %d\n",i,j);                                  
                               }
            if(i==0&&j==0&&sz[0][0]>=sz[0][1]&&sz[0][0]>=sz[1][0]) {
                    printf("%d %d\n",i,j);
            }
            if(i==0&&j==n-1&&sz[0][n-1]>=sz[0][n-2]&&sz[0][n-1]>=sz[1][n-1]) {
                    printf("%d %d\n",i,j);                                
            }
            if(i==m-1&&j==0&&sz[m-1][0]>=sz[m-1][1]&&sz[m-1][0]>=sz[m-2][0]) {
                    printf("%d %d\n",i,j);  
            }
            if(i==m-1&&j==n-1&&sz[m-1][n-1]>=sz[m-1][n-2]&&sz[m-1][n-1]>=sz[m-2][n-1]) {
                 printf("%d %d\n",i,j);  
            }                                                                  
            if((i==0&&j>0&&j<n-1&&sz[i][j]>=sz[i+1][j]&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i][j+1])||(i==m-1&&j>0&&j<n-1&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i][j-1])||(j==0&&i>0&&i<m-1&&sz[i][j]>=sz[i][j+1]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j])||(j==n-1&&i>0&&i<m-1&&sz[i][j]>=sz[i][j-1]&&sz[i][j]>=sz[i-1][j]&&sz[i][j]>=sz[i+1][j])) {
                 printf("%d %d\n",i,j);
             }
       }
   }
return 0;
}
int main()
{
	int m,n,i,j;
	int altitude[21][21]={0};
	cin >>m>>n;
	for (i=0;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			cin >>altitude[i][j];
		}
	}
	i=0;
	if ((altitude[0][0]>=altitude[0][1])&&(altitude[0][0]>=altitude[1][0]))
		cout <<"0 0"<<endl;
	for (j=1;j<n;j++)
	{
		if ((altitude[i][j]>=altitude[i][j-1])&&(altitude[i][j]>=altitude[i][j+1])&&(altitude[i][j]>=altitude[i+1][j]))
			cout <<i<<" "<<j<<endl;
	}
	for (i=1;i<m;i++)
	{
		for (j=0;j<n;j++)
		{
			if (j==0)
			{
				if ((altitude[i][j]>=altitude[i-1][j])&&(altitude[i][j]>=altitude[i][j+1])&&(altitude[i][j]>=altitude[i+1][j]))
					cout <<i<<" "<<j<<endl;
			}
			if (j>0)
			{
				if ((altitude[i][j]>=altitude[i-1][j])&&(altitude[i][j]>=altitude[i][j-1])&&(altitude[i][j]>=altitude[i][j+1])&&(altitude[i][j]>=altitude[i+1][j]))
					cout <<i<<" "<<j<<endl;
			}
		}
	}
	return 0;
}
int main()
{
      int a[25][25],n,m,day,i,j,k,square = 0 , lenth = 0;
        scanf("%d%d",&n,&m);
        memset ( a, 0, sizeof( a ) );
        for( i = 1 ;i <= n;i ++ )
        for( j = 1 ;j <= m;j ++ )
        scanf("%d",&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]))
                 printf( "%d %d\n",i-1,j-1 );
              }
           }
}
int main ()
{
    int a[100][100],b[100][100];
    int i,j,k,l,m,n;
    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][0]&&a[i][0]>=a[i+1][0]&&a[i][0]>=a[i][1])
        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-1][n-1]&&a[i][n-1]>=a[i+1][n-1]&&a[i][n-1]>=a[i][n-2])
        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 main(){
    int m,n,i,j,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++){
        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])||(i==0&&j==n-1&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1])||(i==m-1&&j==n-1&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])
||(i==m-1&&j==0&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j+1])||(i==0&&j<n-1&&j>0&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i][j-1])||(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])||
(j==0&&i<m-1&&i>0&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j])||(j==n-1&&i<m-1&&i>0&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j-1]&&a[i][j]>=a[i-1][j])
||(j<n-1&&j>0&&i<m-1&&i>0&&a[i][j]>=a[i+1][j]&&a[i][j]>=a[i][j+1]&&a[i][j]>=a[i-1][j]&&a[i][j]>=a[i][j-1])){
                printf("%d %d\n",i,j);
            }
        }
}
    return 0;
}
int main(){
    int j=0,k=0,m=0,n=0,i=0;
    scanf("%d%d",&m,&n);
    int dk[20][20];
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            scanf("%d",&(dk[i][j]));
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            if(i==0){
                if(j==0){
                    if(dk[i][j]>=dk[i][j+1]&&dk[i][j]>=dk[i+1][j]){
                        printf("%d %d\n",i,j);
                    }
                }else if(j==n-1){
                    if(dk[i][j]>=dk[i][j-1]&&dk[i][j]>=dk[i+1][j]){
                        printf("%d %d\n",i,j);
                    }
                }else{
                    if(dk[i][j]>=dk[i][j-1]&&dk[i][j]>=dk[i+1][j]&&dk[i][j]>=dk[i][j+1]){
                        printf("%d %d\n",i,j);
                    }
                }
            }else if(i==m-1){
                if(j==0){
                    if(dk[i][j]>=dk[i][j+1]&&dk[i][j]>=dk[i-1][j]){
                        printf("%d %d\n",i,j);
                    }
                }else if(j==n-1){
                    if(dk[i][j]>=dk[i][j-1]&&dk[i][j]>=dk[i-1][j]){
                        printf("%d %d\n",i,j);
                    }
                }else{
                    if(dk[i][j]>=dk[i][j-1]&&dk[i][j]>=dk[i-1][j]&&dk[i][j]>=dk[i][j+1]){
                        printf("%d %d\n",i,j);
                    }
                }
            }else{
                if(j==0){
                    if(dk[i][j]>=dk[i][j+1]&&dk[i][j]>=dk[i-1][j]&&dk[i][j]>=dk[i+1][j]){
                        printf("%d %d\n",i,j);
                    }
                }else if(j==n-1){
                    if(dk[i][j]>=dk[i][j-1]&&dk[i][j]>=dk[i-1][j]&&dk[i][j]>=dk[i+1][j]){
                        printf("%d %d\n",i,j);
                    }
                }else{
                    if(dk[i][j]>=dk[i][j-1]&&dk[i][j]>=dk[i-1][j]&&dk[i][j]>=dk[i][j+1]&&dk[i][j]>=dk[i+1][j]){
                        printf("%d %d\n",i,j);
                    }
                }
            }
        }
    }
    return 0;
}
int main()
{
	int m, n, h[22][22], i, j;

	cin >> m >> n;
	for (i = 1; i <= m; i++)
		for (j = 1; j <= n; j++)
			cin >> h[i][j];
	
	for (i = 0; i <= m + 1; i++)
		h[i][0] = h[i][n + 1] = 0;
	for (j = 1; j <= n; j++)
		h[0][j] = h[m + 1][j] = 0;

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