/*97zf*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    long *p,l,i,a=1,b=1,temp;
    scanf("%ld",&l);
    p=(long*)calloc(l,sizeof(long));
    for(i=0;i<l;i++)
        scanf("%ld",&p[i]);
    for(i=0;i<l-1;i++)
    {
        if(p[i]<p[i+1])
        {
            if((a==1&&b==1)||temp==1)
            {
                a++;
                temp=1;
            }
            else if(a!=1||temp==2)
            {
                b++;
                temp=2;
            }
            else if(b!=1||temp==3)
            {
                a++;
                temp=3;
            }
        }
        else
        {
            if(a>b)
            {
                b=1;
                temp=0;
            }
            else
            {
                a=1;
                temp=0;
            }
        }
    }
    free(p);
    if(a>b) printf("%ld\n",a);
    else printf("%ld\n",b);
    return 0;
}


/*6lux*/
#include<algorithm>
using namespace std;

int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",a+i);
    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i-1]) ans++;
        else ans=1;
    }
    printf("%d",ans);
    return 0;
}


/*45ij*/
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define N 100000
bool cmp(int a,int b)
{
      return a<b;

}
int main()
{
    int  n,i,j=0,count=1;
    int a[N],b[N];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i]<a[i+1]){count++;if((i+1)==(n-1)){b[j]=count;}}
        if(a[i]>=a[i+1]){b[j]=count;j++;count=1;}
    }
    sort(b,b+j,cmp);
    printf("%d",b[0]);
    return 0;
}


/*nhus*/
#include <stdio.h>
int main ()
{
    long int a,b,c,d=0,n;
    scanf("%d",&n);
    scanf("%d",&b);
    for (a=1;a<n;a++)
    {
        scanf("%d",&c);
        if (c>b)d++;
        b=c;
    }
    if (d==0)d++;
    printf("%d",d);
    return 0;
}


/*10yt*/
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int count,ans;
	count=1;
	ans=count;
	for(i=0;i<n;i++){
		if(a[i]<a[i+1]){
			count++;
		}
		else{
			if(ans<count){
				ans=count;
			}
			count=1;
		}
	}
	printf("%d",ans);
	return 0;
}


/*26ye*/
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int count,ans;
	count=1;
	ans=count;
	for(i=0;i<n;i++){
		if(a[i]<a[i+1]){
			count++;
		}
		else{
			if(ans<count){
				ans=count;
			}
			count=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}


/*2zfm*/
#include <iostream>
using namespace std;

int find_max_len_method2(const int *A, int N) {
  int* max_len = new int[N]; // max_len[i]表示以A[i]结尾的那些子序列中的最长长度
  max_len[0] = 1;
  for(int i=1; i<N; i++) { // 依次考虑以A[1],...,A[N-1]结尾的子序列
    max_len[i] = 1;
    for(int j=0; j<i; j++) {
       if(A[i] > A[j]) {
         max_len[i] = max_len[j]+1>max_len[i] ? (max_len[j]+1):max_len[i];
       }
    }
  }
  cout << "max_len" << endl;
  for(int i=0; i<N; i++)
    cout << max_len[i] << " ";
  cout << endl;

  int result = 0;
  for(int i=0; i<N; i++)
    result = max_len[i]>result ? max_len[i]:result;
  delete[] max_len;
  return result;
}

int find_max_len_method3(const int *A, int N) {
  int* len_min_value = new int[N+1];
  int max_len;
  len_min_value[0] = INT_MIN;
  len_min_value[1] = A[0];
  max_len = 1;
  for(int i=1; i<N; i++) { // 依次引入A[1],...,A[N-1]
    int pos = max_len;
    if(A[i] > len_min_value[max_len]) {
      max_len++;
      len_min_value[max_len] = A[i];
    }
    else {
      int j = max_len-1;
      while(A[i] < len_min_value[j])
        j--;
      len_min_value[j+1] = A[i];
    }
  }
  cout << "len_min_value" << endl;
  for(int i=0; i<N+1; i++)
    cout << "d: " << len_min_value[i] << " ";
  cout << endl;
  delete []len_min_value;
  return max_len;
}

int main() {
  int a[8] = {1, -1, 2, -3, 4, -5, 6, -7}; // 1,2,4,6
  cout << "数组：" << endl;
  for(int i=0; i<8; i++)
    cout << a[i] << " ";
  cout << endl;
  cout << "数组的最长递增子序列长度为：" << find_max_len_method2(a, 8) << endl;
  cout << "数组的最长递增子序列长度为：" << find_max_len_method3(a, 8) << endl;
  system("PAUSE");
  return 0;
}


/*7acx*/
#include<stdio.h>
#include<algorithm>
using namespace std;

struct card
{
    int id;
    int value;
};

card a[100];
bool cmp(card a,card b)
{
    return a.value<b.value;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        a[i].id=i+1;
        scanf("%d",&(a[i].value));
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n/2;i++)
    {
        printf("%d %d\n",a[i].id,a[n-1-i].id);
    }
    return 0;
}


/*ijmj*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    scanf("%d",&l)
        p=calloc(l,sizeof(int));
        for(i=0;i<l;i++)
            scanf("%d",&p[i]);
        for(i=0;i<l-1;i++)
        {
            if(p[i]<p[i+1])
            {
                if((a==1&&b==1)||temp==1)
                {
                    a++;
                    temp=1;
                }
                else if(a!=1||temp==2)
                {
                    b++;
                    temp=2;
                }
                else if(b!=1||temp==3)
                {
                    a++;
                    temp=3;
                }
            }
            else
            {
                if(a>b)
                {
                    b=1;
                    temp=0;
                }
                else
                {
                    a=1;
                    temp=0;
                }
            }
        }
        free(p);
        if(a>b) printf("%d",a);
        else printf("%d",b);
    return 0;
}


/*42vs*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    scanf("%d",&l);
    p=(int *)calloc(l,sizeof(int));
    for(i=0;i<l;i++)
        scanf("%d",&p[i]);
    for(i=0;i<l-1;i++)
    {
        if(p[i]<p[i+1])
        {
            if((a==1&&b==1)||temp==1)
            {
                a++;
                temp=1;
            }
            else if(a!=1||temp==2)
            {
                b++;
                temp=2;
            }
            else if(b!=1||temp==3)
            {
                a++;
                temp=3;
            }
        }
        else
        {
            if(a>b)
            {
                b=1;
                temp=0;
            }
            else
            {
                a=1;
                temp=0;
            }
        }
    }
    free(p);
    if(a>b) printf("%d\n",a);
    else printf("%d\n",b);
    return 0;
}


/*4k1k*/
#include<stdio.h>
#include<algorithm>
using namespace std;

int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",a+i);
    int ans=1;
    int max=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i-1])
        {
            ans++;
            if(ans>max) max=ans;
        }
        else
        {

            ans=1;
        }
    }
    printf("%d",max);
    return 0;
}


/*5714*/
#include<stdio.h>
int main()
{
    int n,i,j,p,count;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int max=1;
    for(i=0;i<n;i=j)
    {
        count=1;
        p=i;
        for(j=i+1;j<n;j++)
        {
            if(a[p++]<a[j])
                count++;
            else
                break;
        }
        if(count>max)
            max=count;
    }
    printf("%d\n",max);
    return 0;
}


/*tx00*/
#include <stdio.h>
int main ()
{
    long int a,b,c,d=0,n;
    scanf("%d",&n);
    scanf("%d",&b);
    for (a=1;a<n;a++)
    {
        scanf("%d",&c);
        if (c>b)d++;
        b=c;
    }
    if (d==0)d++;
    printf("%d",d);
    return 0;
}


/*dxri*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    while(scanf("%d",&l))
    {
        p=calloc(l,sizeof(int));
        for(i=0;i<l;i++)
            scanf("%d",&p[i]);
        for(i=0;i<l-1;i++)
        {
            if(p[i]<p[i+1])
            {
                if((a==1&&b==1)||temp==1)
                {
                    a++;
                    temp=1;
                }
                else if(a!=1||temp==2)
                {
                    b++;
                    temp=2;
                }
                else if(b!=1||temp==3)
                {
                    a++;
                    temp=3;
                }
            }
            else
            {
                if(a>b)
                {
                    b=1;
                    temp=0;
                }
                else
                {
                    a=1;
                    temp=0;
                }
            }
        }
        free(p);
        if(a>b) printf("%d",a);
        else printf("%d",b);
    }
    return 0;
}


/*2fq6*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100010];
int dp[100010];
int main()
{
    int n,i,j,k,l;
    while(scanf("%d",&n)!=EOF)
    {
       memset(a,0,sizeof(a));
       memset(dp,0,sizeof(dp));
       int maxx=0;
       for(i=1;i<=n;i++)
       scanf("%d",&a[i]);
       dp[1]=1;
       for(i=2;i<=n;i++)
       {
           if(a[i]>a[i-1])
           dp[i]=dp[i-1]+1;
           else
           dp[i]=1;
       }
       for(i=1;i<=n;i++)
       maxx=max(maxx,dp[i]);
       printf("%d\n",maxx);
    }
    return 0;
}


/*e0kb*/
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define N 100000

int main()
{
    int  n,i,j=0,count=1,max;
    int a[N],b[N];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i]<a[i+1]){count++;if((i+1)==(n-1)){b[j]=count;}}
        if(a[i]>=a[i+1]){b[j]=count;j++;count=1;}
    }
    for(i=0;i<j;i++)
    {
        max=b[0];
        if(b[i]>max)max=b[i];
    }
    printf("%d",max);
    return 0;
}


/*q17g*/
#define LOCAL
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
#ifdef LOCAL
	freopen("data.in", "r",stdin);
	freopen("data.out", "w",stdout);
#endif // LOCAL
	int n, a, b, res = 1, result = 1;
	scanf("%d", &n);
	scanf("%d", &a);
	for (int i = 1; i<n; i++) {
		scanf("%d", &b);
		if (b>a) {
			res++;
		}
		else {
			res = 1;
		}
		a = b;
		if (res>result)
			result = res;
	}
	printf("%d\n", result);
	return 0;
}


/*e6sw*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    long long *p,l,i,a=1,b=1,temp;
    scanf("%I64d",&l);
    p=(long long*)calloc(l,sizeof(long long));
    for(i=0;i<l;i++)
        scanf("%I64d",&p[i]);
    for(i=0;i<l-1;i++)
    {
        if(p[i]<p[i+1])
        {
            if((a==1&&b==1)||temp==1)
            {
                a++;
                temp=1;
            }
            else if(a!=1||temp==2)
            {
                b++;
                temp=2;
            }
            else if(b!=1||temp==3)
            {
                a++;
                temp=3;
            }
        }
        else
        {
            if(a>b)
            {
                b=1;
                temp=0;
            }
            else
            {
                a=1;
                temp=0;
            }
        }
    }
    free(p);
    if(a>b) printf("%I64d\n",a);
    else printf("%I64d\n",b);
    return 0;
}


/*ltcs*/
#include <stdio.h>
#define N 100000
int main()
{
    int number[N];
    int count[N] = {0};
    int n, i, j;
    int max;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &number[i]);
    }
    j = 0;
    i = 0;
    while(i < n-1)
    {
        if(number[i] < number[i+1])
        {
            count[j]++;
            i++;
        }
        else
        {
            j++;
            i++;
        }
    }
    max = count[0];
    for(i=0; i<=j; i++)
    {
        max = max > count[i] ? max : count[i];
    }
    printf("%d", max+1);
    return 0;
}


/*y2j9*/
#include <stdio.h>

int main()
{
    int n;
    int index;
    int max = 0;
    int a[100001];
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i ++)
    {
        int index = i;
        while (a[index] < a[index + 1])
            index ++;
        if (index - i + 1 > max)
            max = index - i + 1;
    }
    printf("%d\n", max);
    return 0;
}


/*rgjn*/
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
	int n, a, b, res = 1, result = 1;
	scanf("%d", &n);
	scanf("%d", &a);
	for (int i = 1; i<n; i++) {
		scanf("%d", &b);
		if (b>a) {
			res++;
		}
		else {
			res = 1;
		}
		a = b;
		if (res>result)
			result = res;
	}
	printf("%d\n", result);
	return 0;
}


/*eqzg*/
#include<stdio.h>
int main()
{
	int n,a[120],i,longth;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	longth=1;
	for(i=0;i<n-1;i++)
	{
		if(a[i+1]>a[i])
		longth++;
		else
		longth=1;
	}
	printf("%d",longth);
	return 0;
}


/*pqu9*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    scanf("%d",&l)
        p=calloc(l,sizeof(int));
        for(i=0;i<l;i++)
            scanf("%d",&p[i]);
        for(i=0;i<l-1;i++)
        {
            if(p[i]<p[i+1])
            {
                if((a==1&&b==1)||temp==1)
                {
                    a++;
                    temp=1;
                }
                else if(a!=1||temp==2)
                {
                    b++;
                    temp=2;
                }
                else if(b!=1||temp==3)
                {
                    a++;
                    temp=3;
                }
            }
            else
            {
                if(a>b)
                {
                    b=1;
                    temp=0;
                }
                else
                {
                    a=1;
                    temp=0;
                }
            }
        }
        free(p);
        if(a>b) printf("%d",a);
        else printf("%d",b);
    return 0;
}


/*i8cj*/
#include<stdio.h>
int main()
{
    int n,a,b,c,d,i;
    scanf("%d",&n);

    int x[n];
    int y[n];
    for(i=0;i<n;i++)
    {
        scanf("%d,",&x[i]);
    }
    b=1;
    for(a=0,d=0;a<n;a=a+b,d++)
    {
        for(c=a+1;c<n;c++)
        {
            if(x[c]>x[a])
            {
                b++;
            }
            else
            {
                y[d]=b;
                break;
            }

        }
    }
    bubble(y,n);
    printf("%d",y[n-1]);
}

void bubble(int y[],int n)

{

int i,j,temp;

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

for(j=i+1;j<n;j++)

if(y[i]>y[j])
    {

temp=y[i];

y[i]=y[j];

y[j]=temp;

}

}


/*iqji*/
#include <iostream>
#include <algorithm>
using namespace std;

int b[100000],a[1000];

bool compare(int a,int b)
{
      return a>b;
}

int main()
{
	int n,k=1,l=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(b[i]<b[i+1])
			{
				k++;
			}
		else
		{
			a[l++]=k;
			k=1;
		}
	}
	a[l]=k;
	sort(a,a+l,compare);
	cout<<a[0]<<endl;
	return 0;
}


/*3tg2*/
#include <cstdio>
#include<algorithm>
#define MAX 100005
using namespace std;
int shu[MAX];
int comp[MAX];
int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        for(int i=0;i<n;i++)
            scanf("%d",&shu[i]);
        int num=0;
        int con=1;
        for(int i=0;i<n-1;i++)
        {
            if(shu[i]<shu[i+1])
            {
                con++;
                if(i==n-2)
                    comp[num++]=con;
            }
            else
            {
                comp[num++]=con;
                con=1;
            }
        }
        sort(comp,comp+num);
        printf("%d\n",comp[num-1]);
    }
    return 0;
}


/*5kl0*/
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n, a, b, res = 1, result = 1;
	scanf("%d", &n);
	scanf("%d", &a);
	for (int i = 1; i<n; i++) {
		scanf("%d", &b);
		if (b>a) {
			res++;
		}
		else {
			res = 1;
		}
		a = b;
		if (res>result)
			result = res;
	}
	printf("%d\n", result);
	return 0;
}


/*dn2o*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p,l,i,a=1,b=1,temp;
    scanf("%d",&l);
    p=calloc(l,sizeof(int));
    for(i=0;i<l;i++)
        scanf("%d",&p[i]);
    for(i=0;i<l-1;i++)
    {
        if(p[i]<p[i+1])
        {
            if((a==1&&b==1)||temp==1)
            {
                a++;
                temp=1;
            }
            else if(a!=1||temp==2)
            {
                b++;
                temp=2;
            }
            else if(b!=1||temp==3)
            {
                a++;
                temp=3;
            }
        }
        else
        {
            if(a>b)
            {
                b=1;
                temp=0;
            }
            else
            {
                a=1;
                temp=0;
            }
        }
    }
    free(p);
    if(a>b) printf("%d",a);
    else printf("%d",b);
    return 0;
}


/*c8z5*/
#include<stdio.h>

int a[100000];
int main()
{
	int n,i;
	while(scanf("%d", &n)==1)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
		}
		int cnt=1,max=1;
		for(i=0;i<n-1;i++)
		{
			if(a[i]<a[i+1])
			{
				cnt++;
				if(cnt>=max)
				{
					max=cnt;
				}
			}else{
				cnt=1;
			}
		}
		printf("%d\n", max);
	}
	return 0;
}


/*sxl9*/
#include<iostream>
using namespace std;
void main(){
 int n;
 cin>>n;
 int *a,*b;
 a=new int [n];
 b=new int [n];
 for(int i=0;i<n;i++){
  cin>>a[i];
  b[i]=1;
 }
 for(int i=0;i<n;i++){
   int i1=i;
   while(a[i1]>a[i1-1]&&i-1>=0)
	 {  b[i]++; i1--;
   }
 }
 int max=1;
 for(int i=0;i<n;i++){
  if(max<b[i])max=b[i];
 }
 cout<<max;
 system("pause");

}


/*baj8*/
#include<stdio.h>
int main()
{
    int n,i,j,p,count;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int max=1;
    for(i=0;i<n;i++)
    {
        count=1;
        p=i;
        for(j=i+1;j<n;j++)
        {
            if(a[p++]<a[j])
                count++;
            else
                break;
        }
        if(count>max)
            max=count;
    }
    printf("%d\n",max);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n, m, c;
long long a;

int main(){
	cin >> n;
	m = -1;
	c = 0;
	for(int i = 0 ; i < n ; i++){
		cin >> a;
		if(a > m){
			m = a;
			c++;
		}
		else{
			m = a;
			c = 1;
		}
	}
	cout << c;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, b = 0;
	cin >> n;
	int num[n];
	for(int i = 0 ; i < n ; i++)
		cin >> num[i];
	for(int i = 0 ; i < n ; i++){
		int j = 1, bb = 1;
		while(true){
			if(i + j == n)
				break;
			if(num[i + j - 1] < num[i + j])
				bb++;
			if(num[i + j - 1] == num[i + j] || num[i + j - 1] > num[i + j])
				break;
			j++;
		}
		if(bb > b)
			b = bb;
	}
	cout << b;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, b = 0;
	cin >> n;
	int num[n];
	for(int i = 0 ; i < n ; i++)
		cin >> num[i];
	for(int i = 0 ; i < n ; i++){
		int j = 1, bb = 1;
		while(true){
			if(num[i + j - 1] < num[i + j])
				bb++;
			if(num[i + j - 1] == num[i + j] || num[i + j - 1] > num[i + j])
				break;
			j++;
		}
		if(bb > b)
			b = bb;
	}
	cout << b;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, b = 0;
	cin >> n;
	int num[n];
	for(int i = 0 ; i < n ; i++)
		cin >> num[i];
	for(int i = 0 ; i < n ; i++){
		int j = 1, bb = 1;
		while(true){
			if(num[i + j - 1] < num[i + j])
				bb++;
			else
				break;
			j++;
		}
		if(bb > b)
			b = bb;
	}
	cout << b;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, b = 0;
	cin >> n;
	long long num[n];
	long long s_num[n];
	for(int i = 0 ; i < n ; i++){
		cin >> num[i];
		s_num[i] = num[i];
	}

	sort(s_num, s_num + n);

	if(*s_num == *num)
		cout << n;

	else{
		for(int i = 0 ; i < n ; i++){
			int j = 1, bb = 1;
			if(b >= n - i)
				break;
			while(true){
				if(i + j == n)
					break;
				if(num[i + j - 1] < num[i + j])
					bb++;
				if(num[i + j - 1] == num[i + j] || num[i + j - 1] > num[i + j])
					break;
				j++;
			}
			if(bb > b)
				b = bb;
		}
		cout << b;

	}
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, b = 0;
	cin >> n;
	long long num[n];
	for(int i = 0 ; i < n ; i++)
		cin >> num[i];
	for(int i = 0 ; i < n ; i++){
		int j = 1, bb = 1;
		if(b >= n - i)
			break;
		while(true){
			if(i + j == n)
				break;
			if(num[i + j - 1] < num[i + j])
				bb++;
			if(num[i + j - 1] == num[i + j] || num[i + j - 1] > num[i + j])
				break;
			j++;
		}
		if(bb > b)
			b = bb;
	}
	cout << b;
}


#include<bits/stdc++.h>
using namespace std;

int n, m, c;
long long a;

int main(){
	cin >> n;
	m = -1;
	c = 1;
	for(int i = 0 ; i < n ; i++){
		cin >> a;
		if(a > m){
			m = a;
			c++;
		}
		else{
			m = a;
			c = 1;
		}
	}
	cout << c;
}


#include<bits/stdc++.h>
using namespace std;

int n, c, cc;
long long a, m;

int main(){
	cin >> n;
	m = -1;
	c = 0;
	for(int i = 0 ; i < n ; i++){
		cin >> a;
		if(a > m){
			m = a;
			c++;
			cc = max(c, cc);
		}
		else{
			m = a;
			c = 1;
		}
	}
	cout << cc;
}


#include<bits/stdc++.h>
using namespace std;
int n,a,b,r,m;
int main()
{
	cin>>n;
	for(int x=1;x<=n;x++){
		cin>>b;
		if(b>a)r++;
		if(b<=a||x==n)m=max(m,r),r=1;
		a=b;
	}
	cout<<m;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100005],ans=0,maxx=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]>a[i-1]?ans++:ans=1;
		maxx=max(maxx,ans);
	}
	cout<<maxx<<endl;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,a[100010],f=1,ans=0;
	cin>>n>>a[1];
	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>a[i-1]) f++;
		else
		{
			if(f>ans) ans=f;
			f=1;
		}
	}
	if(f>ans) ans=f;
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
    int n,ans=1,maxn=1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    for(int i=2;i<=n;++i){
    	if(a[i]>a[i-1]) ans++;
    	else{
    		if(ans>maxn){
    			maxn=ans;
    			ans=1;
			}
		}
	}
	maxn=max(ans,maxn);
	printf("%d",maxn);
    return 0;
}


#include<iostream>
using namespace std;
long long n,a[100005],ans=1,maxn=0;
int max(int x,int y)
{
	return x>y?x:y;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>a[1];
	for(register int i=2;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>a[i-1]) ans++;
		else
		{
			maxn=max(maxn,ans);
			ans=1;
		}
	}
	cout<<maxn;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int mae=-1;
	int ans=1;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		if(a>mae)
		{
			cnt++;
			if(cnt>ans)
			ans=cnt;
		}
		else
		{
			cnt=1;
		}
		mae=a;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0,ansx=1,n,a[100001];
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i+1]) ansx++;
		else
		{
			ansx=1;
			if(ansx>ans) ans=ansx;
		}
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,max1,tt=1;
	cin >> n;
	cin >> a[1];
	for(int i=2;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>a[i-1])
			tt++;
		else
		{
			max1=max(max1,tt);
			tt=1;
		}
	}
	max1=max(max1,tt);
	cout << max1 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000010],cnt=0,ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=2;i<=n;i++)
    {
    	if(a[i]>a[i-1])
        {
            cnt++;
            ans=max(ans,cnt);
        }
        else
            cnt=0;
    }
    cout<<ans+1<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
int a[maxn];
int f[maxn];
int main()
{
    int n=0;
    int l,r,mid;
    cin>>n;
    for(int i=1;i<=n;i++)
		cin>>a[i];
    f[0]=1234123412;
    int ans1=0;
    for(int i=1;i<=n;i++){
           if(f[ans1]>=a[i]){
                f[ans1+1]=a[i];
                ans1++;
        }
        else{
                l=0;r=ans1;
                while(l<r){
                    mid=(l+r)/2;
                    if(f[mid]>=a[i])l=mid+1;
                    else{
                        r=mid;
                }
            }
            if(l!=0)f[l]=a[i];
        }
    }
    cout<<ans1<<endl;

}


//7777777
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#define lson l , m , rt << 1
#define rson m+1 , r , rt << 1 | 1
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double pi = 3.1415926535;
const double eps = 1e-6;
const int MXN = 1e5 + 7;
const int MXM = 3e5 + 7;
const int MX = 1e5 + 7;
const int maxbit = 18;
const double val = pi/180.0;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 2e9 + 7;
int a[MX];
int main()
{
	int n;
	cin>>n;
	for(int i = 1; i <= n;++i)
	{
		cin>>a[i];
	}
	int ans = 1;
	int len = 0;
	for(int i = 1;i <= n + 1;++i)
	{
		if(a[i] > a[i-1]){
			len ++;
		}
		else{
			ans = max(ans,len);
			len = 1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int s[100010];
int dp[100010];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		dp[i] = 1;
	}
	for (int i = 2; i <= n; i++) {
		if (s[i - 1] < s[i]) {
			dp[i] = max(dp[i], dp[i - 1] + 1);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, ans = 0, last = 0, t = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++ ) {
		int x;
		scanf("%d", &x);
		if (x > last) {
			t ++;
			last = x;
		}
		else {
			ans = max(ans, t);
			t = 1;
			last = x;
		}
	}
	ans = max(ans, t);
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,max1,tt=1;
	cin >> n;
	cin >> a[1];
	for(int i=2;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]>a[i-1])
			tt++;
		else
		{
			max1=max(max1,tt);
			tt=1;
		}
	}
	max1=max(max1,tt);
	cout << max1;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
int n,a=0,b=0,sum=0,c;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int ans;
		cin>>ans;
		if(ans>a) b++;
		else
		{
			sum=max(ans,b);
			b=1;
		}
		a=ans;
	}
	c=max(sum,b);
	cout<<c;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
 int main()
   {
   	int a[10001],n,i,k,max;
   	cin>>n;
   	for(i=1;i<=n;i++) cin>>a[i];
   	k=1;
   	max=1;
   	for(i=2;i<=n;i++)
   	 if(a[i]==a[i-1]+1) k++;
   	  else
   	   {
   	   	if(k>max) max=k;
   	   	k=1;
	   }
    cout<<max;
   	return 0;
   }


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include <algorithm>
using namespace std;
int num[100020];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
	}
	int mx=0;
	for(int i=1;i<=n;i++)
	{
		int cnt=1;
		if(num[i]<num[i+1])
		{
			cnt++;
			if(cnt>mx)mx=cnt;
		}
		else
		{
			cnt=1;
		}
	}
	printf("%d",mx+1);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define N 110000
int a[N];
int main()
{
    ios::sync_with_stdio(false);
	int n;
    std::cin>>n;
    int ans=1,t=1;
    std::cin>>a[0];
    for(register int i=1;i<n;i++)
	{
        std::cin>>a[i];
        if(a[i]>a[i-1])
        	t++;
        else
		{
            ans=max(ans,t);
            t=1;
        }
    }
    ans=max(ans,t);
    std::cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int a[N],b[N];
int main()
{
	int n,k=1,j=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1]) k++;
		else
		{
			b[j]=k;
			j++;
		}
	}
	sort(b,b+j);
	cout<<b[j]<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define max(a,b) a>b?a:b
using namespace std;
int a[100010];
int main()
{
    int n;
    cin>>n;
    int ans=1,t=1;
    cin>>a[0];
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>a[i-1]) t++;
        else
        {
            ans=max(ans,t);
            t=1;
        }
    }
    ans=max(ans,t);
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[100001],n,ans=1,temp=0;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for (int i=1; i<n; i++)
    {
        if (a[i+1]>a[i]) temp++;
        if (a[i+1]<=a[i]||i==n-1)
        {
            if (temp+1>ans) ans=temp+1;
            temp=0;
        }
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
    int n,ans=1,maxn=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    for(int i=1;i<=n;++i){
    	if(a[i]>a[i+1]) ans++;
    	else{
    		if(ans>maxn) maxn=ans;
		}
	}
	printf("%d",maxn);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[2],ans,ct;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i%2];
        if(a[i%2]>a[(i+1)%2]){
            ct++;
            ans=max(ans,ct);
        }
        else{
            ans=max(ans,ct);
            now=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
    int n,ans=1,maxn=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    a[n+1]=-1;
    for(int i=2;i<=(n+1);++i){
    	if(a[i]>a[i-1]) ans++;
    	else{
    		if(ans>maxn){
    			maxn=ans;
    			ans=1;
			}
		}
	}
	printf("%d",maxn);
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    long long i,t=1,k=1,n,a[100001];
    cin>>n;
    for(i=1;i<=n;++i)
        cin>>a[i];
    for(i=1;i<n;++i)
        if(a[i]<a[i+1])
            {
                ++t;
                if(k<=t)
                    k=t;
            }
        else
            t=1;
    cout<<k<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,e,f;
int main()
{
	cin>>a;
	for(int d=0;d<a;d++)
	{
		cin>>b;
		if(b>c)
		{
			e++;
		}
		else
		{
			e=1;
		}
		f=max(e,f);
		c=b;
	}
	cout<<f;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int hyf[100010];
int main()
{
    long long n,n1,m1,m,j,k,i,t=-999,x,y,t1=1;
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>hyf[i];
    for(i=2;i<=n;i++)
    {
    	if(hyf[i]>hyf[i-1])
		t1++;
		else
		{
			if(t1>t)
			{
				t=t1;
			}
			t1=1;
		}
	}
	cout<<max(t1,t);
}


#include<bits/stdc++.h>

using namespace std;

int n;
int a[100010];
int ans = 0;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int l = 1;
	int r = 1;
	while(r <= n)
	{
		while(a[r+1] > a[r])
		{
			r++;
		}
		ans = max(ans, r - l  + 1);
		r++;
		l = r;
	}
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
	int n,i,last,sum=0,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	last=a[1];
	for(i=1;i<=n+1;i++)
	{
		if(a[i]>last)
		{
			sum++;
		}
		else
		{
			ans=max(sum,ans);
			sum=1;
		}
		last=a[i];
	}
	printf("%d",ans);
	return 0;
}


#include<iostream>
using namespace std;
int n,a[2333333],dp[23333333];
int ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) {
	cin>>a[i];
	dp[i]=1;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>a[i-1]) dp[i]=max(dp[i],dp[i-1]+1);
	}

	for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int x=0,y=0,n,s=0,t=0;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x>y)t++;
		else s=max(t,s),t=1;
		y=x;
	}
	cout<<max(s,t);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int now=0,a[2],n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i%2]);
        if(a[i%2]>a[(i+1)%2])
        {
            now++;
            ans=max(ans,now);
        }
        else
        {
            ans=max(ans,now);
            now=1;
        }
    }
    cout<<ans<<endl;
    return 0;
 }


#include<cstdio>
using namespace std;
int a,b,n,ans,max,i;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		a=b;scanf("%d",&b);
		if(a<b) ans++;
		else {
			if(ans>max) max=ans;
			ans=1;
		}
	}
	if(ans>max) max=ans;
	printf("%d",max);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int num[n+1],maxlen=1,zc[n+1],t;
	for(int i=1;i<=n;i++)
		cin>>num[i];
	zc[1]=num[1];
	for(int i=2;i<=n;i++){
		if(zc[maxlen]<num[i]){
			maxlen++;
			zc[maxlen]=num[i];
		}
		else{
			t=lower_bound(zc,zc+maxlen,num[i])-zc;
			zc[t]=num[i];
		}
	}
	cout<<maxlen;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[1000001],i,n,s=1,v=0;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=2;i<=n;i++){
		if(a[i]>a[i-1]){
			s++;
		}
		else{
			if(s>v)
				v=s;
			s=1;
		}
	}
	if(s>v)
				v=s;
	cout<<v;
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
    int n,ans=1,maxn=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    for(int i=1;i<=n;++i){
    	if(a[i]>a[i-1]) ans++;
    	else{
    		if(ans>maxn){
    			maxn=ans;
    			ans=1;
			}
		}
	}
	printf("%d",maxn);
    return 0;
}


#include<iostream>
using namespace std;
int a[100010],p,sum=1,k=1;
int main(){
    cin>>p>>a[0];
    for(register int i=1;i<p;i++){
        cin>>a[i];
        if(a[i]>a[i-1])
			k++;
        else{
            sum=max(sum,k);
            k=1;
        }
    }
    sum=max(sum,k);
    cout<<sum<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1],i;
    cin>>a[0];
    for (i=1;i<n;i++)
    {
        cin>>a[i];
    }
    int res,f;
    res=f=1;
    for(i=1;i<n;i++)
    {
        if(a[i]>a[i-1])
        {
            f++;
        }
        else
        {
            res=max(res,f);
            f=1;
        }
    }
    res=max(res,f);
    cout<<res;
}


#include<iostream>
#define max(a,b) a>b?a:b
using namespace std;
int a[100010];
int main(){
    int n;
    cin>>n;
    int ans=1,t=1;
    cin>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i]>a[i-1]) t++;
        else{
            ans=max(ans,t);
            t=1;
        }
    }
    ans=max(ans,t);
    cout<<ans;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int n,last,a,t,maxn;
int main(){
    cin>>n>>last;
    for(int i=2;i<=n;i++){
    	cin>>a;
    	if(a>last){
    		t++;
    		maxn=max(t,maxn);
		}
		else t=0;
		last=a;
	}
	cout<<maxn+1;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct abc{
    int val, taken;
};
struct abc arr[105][105];
int main()
{
    int n, m, i, j, coun, one[105], two[105], one_input, k;
    cin >> n >> m;
    for(i = 0, one_input = 0; i < n; i++)
        for(j = 0; j < m; j++){
            scanf("%d", &arr[i][j].val);
            if(arr[i][j].val == 1) one_input++;
        }
    for(i = 0, coun = 0, k = 0;  i< n-1; i++)
        for(j = 0; j < m-1; j++)
            if(arr[i][j].val == 1 && arr[i+1][j].val == 1 &&arr[i][j+1].val == 1 &&arr[i+1][j+1].val == 1){
                if(arr[i][j].taken == 0) coun++, arr[i][j].taken = -1;
                if(arr[i+1][j].taken == 0) coun++, arr[i+1][j].taken = -1;
                if(arr[i][j+1].taken == 0) coun++, arr[i][j+1].taken = -1;
                if(arr[i+1][j+1].taken == 0) coun++, arr[i+1][j+1].taken = -1;
                one[k] = i+1, two[k] = j+1, k++;
            }
    if(coun == one_input){ cout << k << endl;
        for(i = 0; i < k; i++) printf("%d %d\n", one[i], two[i]);
    }
    else cout << -1 << endl;
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    struct abc{
        bool val, taken;
    };
    struct abc arr[105][105];
    int main()
    {
        int n, m, i, j, coun, one[105], two[105], one_input, k;
        cin >> n >> m;
        for(i = 0, one_input = 0; i < n; i++)
            for(j = 0; j < m; j++){
                scanf("%d", &arr[i][j].val);
                if(arr[i][j].val == 1) one_input++;
            }
        for(i = 0, k = 0;  i< n-1; i++)
            for(j = 0; j < m-1; j++){
                if(arr[i][j].val&& arr[i+1][j].val&&arr[i][j+1].val&&arr[i+1][j+1].val){
                    arr[i][j].taken = 1;
                    arr[i+1][j].taken = 1;
                    arr[i][j+1].taken = 1;
                    arr[i+1][j+1].taken = 1;
                    one[k] = i+1, two[k] = j+1, k++;
                }
            }
        for(i = 0, coun = 0; i < n; i++)
            for(j = 0; j < m; j++)
                if(arr[i][j].val && arr[i][j].taken) coun++;

        if(coun == one_input){ printf("%d\n", k);
            for(i = 0; i < k; i++) printf("%d %d\n", one[i], two[i]);
        }
        else printf("-1\n");
        return 0;
    }


    #include <bits/stdc++.h>
    using namespace std;
    struct abc{
        bool val, taken;
    };
    struct abc arr[105][105];
    int main()
    {
        int n, m, i, j, coun, one[105], two[105], one_input, k;
        cin >> n >> m;
        for(i = 0, one_input = 0; i < n; i++)
            for(j = 0; j < m; j++){
                scanf("%d", &arr[i][j].val);
                if(arr[i][j].val) one_input++;
            }
        for(i = 0, k = 0;  i< n-1; i++)
            for(j = 0; j < m-1; j++){
                if(arr[i][j].val&& arr[i+1][j].val&&arr[i][j+1].val&&arr[i+1][j+1].val){
                    arr[i][j].taken = 1;
                    arr[i+1][j].taken = 1;
                    arr[i][j+1].taken = 1;
                    arr[i+1][j+1].taken = 1;
                    one[k] = i+1, two[k] = j+1, k++;
                }
                if(arr[i][j].taken) coun++;
            }
        for(i = 0, coun = 0; i < n; i++){
            for(j = 0; j < m; j++)
                if(arr[i][j].taken) coun++;
        }

        if(coun == one_input){ printf("%d\n", k);
            for(i = 0; i < k; i++) printf("%d %d\n", one[i], two[i]);
        }
        else printf("-1\n");
        return 0;
    }


                #include <bits/stdc++.h>
                using namespace std;
                struct abc{
                    bool val, taken;
                };
                struct abc arr[1010][1010];
                int main()
                {
                    int n, m, i, j, coun, one[1000005], two[1000005], one_input, k;
                    cin >> n >> m;
                    for(i = 0, one_input = 0; i < n; i++)
                        for(j = 0; j < m; j++){
                            scanf("%d", &arr[i][j].val);
                            if(arr[i][j].val) one_input++;
                        }
                    for(i = 0, k = 0;  i< n-1; i++)
                        for(j = 0; j < m-1; j++){
                            if(arr[i][j].val+arr[i+1][j].val+arr[i][j+1].val+arr[i+1][j+1].val == 4){
                                arr[i][j].taken = 1;
                                arr[i+1][j].taken = 1;
                                arr[i][j+1].taken = 1;
                                arr[i+1][j+1].taken = 1;
                                one[k] = i+1, two[k] = j+1, k++;
                            }
                            if(arr[i][j].taken) coun++;
                        }
                    for(i = 0, coun = 0; i < n; i++){
                        for(j = 0; j < m; j++)
                            if(arr[i][j].taken) coun++;
                    }

                    if(coun == one_input){ printf("%d\n", k);
                        for(i = 0; i < k; i++) printf("%d %d\n", one[i], two[i]);
                    }
                    else printf("-1\n");
                    return 0;
                }


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51];
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    for(int i = 1; i<=m; i++)
    {
        if(A[1][i] == 1 && A[2][i] == 0 && A[2][i-1] == 1)
            impossible = true;
        if(A[n][i] == 1 && A[n-1][i] == 0 && A[n-1][i-1] == 1)
            impossible = true;
    }
    for(int i =1;i<=n; i++)
    {
        if(A[i][1] == 1 && A[i][2] == 0 && A[i-1][2] == 1)
            impossible = true;
        if(A[i][m] == 1 && A[i][m-1] == 0 && A[i-1][m-1] == 1)
            impossible = true;
    }
    if(A[1][1] == 0 && (A[1][2] == 1 || A[2][1] == 1 || A[2][2] == 1))
        impossible = true;
    if(A[1][m] == 0 && A[2][m] == 1 && A[2][m-1] == 0)
        impossible = true;
    if(A[n][1] == 0 && A[n][2] == 1 && A[n-1][2] == 0)
        impossible = true;

    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] != 0 && A[i+1][j] != 0 && A[i][j+1] != 0 && A[i+1][j+1] != 0)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                }
            }
        }
    }
    if(isOne)
    {
        cout << res << endl;
        for(int i = 1;i<=res; i++)
            cout << results[i].first << " " << results[i].second << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51], B[51][51] = {0};
pair <int, int> results[2501];
bool isOne = false;

int main(){
    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] == 1 && A[i+1][j] == 1 && A[i][j+1] == 1 && A[i+1][j+1] == 1)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                    B[i][j] = B[i+1][j] = B[i][j+1] = B[i+1][j+1] = 1;
                }
            }
        }
    }
    if(isOne)
    {
        for(int i = 1; i<=n; i++)
        {
            for(int j = 1; j<=m; j++)
                if(A[i][j] != B[i][j])
                {
                    impossible = true;
                    cout << -1;
                    break;
                }
            if(impossible)
                break;
        }
        //cout << "hello";
        if(!impossible)
        {
            cout << res << endl;
            for(int i = 1;i<=res; i++)
                cout << results[i].first << " " << results[i].second << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51];
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    for(int i = 1; i<=m; i++)
    {
        if(A[1][i] == 1 && A[2][i] == 0)
            impossible = true;
        if(A[n][i] == 1 && A[n-1][i] == 0)
            impossible = true;
    }
    for(int i =1;i<=n; i++)
    {
        if(A[i][1] == 1 && A[i][2] == 0)
            impossible = true;
        if(A[i][m] == 1 && A[i][m-1] == 0)
            impossible = true;
    }
    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] != 0 && A[i+1][j] != 0 && A[i][j+1] != 0 && A[i+1][j+1] != 0)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                }
            }
        }
    }
    cout << res << endl;
    for(int i = 1;i<=res; i++)
        cout << results[i].first << " " << results[i].second << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51];
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    for(int i = 1; i<=m; i++)
    {
        if(A[1][i] == 1 && A[2][i] == 0)
            impossible = true;
        if(A[n][i] == 1 && A[n-1][i] == 0)
            impossible = true;
    }
    for(int i =1;i<=n; i++)
    {
        if(A[i][1] == 1 && A[i][2] == 0)
            impossible = true;
        if(A[i][m] == 1 && A[i][m-1] == 0)
            impossible = true;
    }
    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] != 0 && A[i+1][j] != 0 && A[i][j+1] != 0 && A[i+1][j+1] != 0)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                }
            }
        }
    }
    if(isOne)
    {
        cout << res << endl;
        for(int i = 1;i<=res; i++)
            cout << results[i].first << " " << results[i].second << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51];
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    for(int i = 1; i<=m; i++)
    {
        if(A[1][i] == 1 && A[2][i] == 0)
            impossible = true;
        if(A[n][i] == 1 && A[n-1][i] == 0)
            impossible = true;
    }
    for(int i =1;i<=n; i++)
    {
        if(A[i][1] == 1 && A[i][2] == 0)
            impossible = true;
        if(A[i][m] == 1 && A[i][m-1] == 0)
            impossible = true;
    }
    if(A[1][1] == 0 && (A[1][2] == 1 || A[2][1] == 1 || A[2][2] == 1))
        impossible = true;
    if(A[1][m] == 0 && A[2][m] == 1)
        impossible = true;
    if(A[n][1] == 0 && A[n][2] == 1)
        impossible = true;
    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] != 0 && A[i+1][j] != 0 && A[i][j+1] != 0 && A[i+1][j+1] != 0)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                }
            }
        }
    }
    if(isOne)
    {
        cout << res << endl;
        for(int i = 1;i<=res; i++)
            cout << results[i].first << " " << results[i].second << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51], B[51][51] = {0};
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] == 1 && A[i+1][j] == 1 && A[i][j+1] == 1 && A[i+1][j+1] == 1)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                    B[i][j] = B[i+1][j] = B[i][j+1] = B[i+1][j+1] = 1;
                }
            }
        }
    }
    if(isOne)
    {
        for(int i = 1; i<=n; i++)
            for(int j = 1; j<=m; j++)
                if(A[i][j] != B[i][j])
                {
                    impossible = true;
                    cout << -1;
                    break;
                }
        if(!impossible)
        {
            cout << res << endl;
            for(int i = 1;i<=res; i++)
                cout << results[i].first << " " << results[i].second << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51], B[51][51] = {0};
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] == 1 && A[i+1][j] == 1 && A[i][j+1] == 1 && A[i+1][j+1] == 1)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                    B[i][j] = B[i+1][j] = B[i][j+1] = B[i+1][j+1] = 1;
                }
            }
        }
    }
    if(isOne)
    {
        for(int i = 1; i<=n; i++)
        {
            for(int j = 1; j<=m; j++)
                if(A[i][j] != B[i][j])
                {
                    impossible = true;
                    cout << -1;
                    break;
                }
            if(impossible)
                break;
        }
        //cout << "hello";
        if(!impossible)
        {
            cout << res << endl;
            for(int i = 1;i<=res; i++)
                cout << results[i].first << " " << results[i].second << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51];
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    bool impossible = false;
    for(int i = 1; i<=m; i++)
    {
        if(A[1][i] == 1 && A[2][i] == 0)
            impossible = true;
        if(A[n][i] == 1 && A[n-1][i] == 0)
            impossible = true;
    }
    for(int i =1;i<=n; i++)
    {
        if(A[i][1] == 1 && A[i][2] == 0)
            impossible = true;
        if(A[i][m] == 1 && A[i][m-1] == 0)
            impossible = true;
    }
    if(A[1][1] == 0 && (A[1][2] == 1 || A[2][1] == 1 || A[2][2] == 1))
        impossible = true;
    if(A[1][m] == 0 && A[2][m] == 1 && A[2][m-1] == 0)
        impossible = true;
    if(A[n][1] == 0 && A[n][2] == 1 && A[n-1][2] == 0)
        impossible = true;

    int res = -1;
    if(!isOne)
        cout << 0 << endl;
    else if(isOne && !impossible){
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] != 0 && A[i+1][j] != 0 && A[i][j+1] != 0 && A[i+1][j+1] != 0)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                }
            }
        }
    }
    if(isOne)
    {
        cout << res << endl;
        for(int i = 1;i<=res; i++)
            cout << results[i].first << " " << results[i].second << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m;
int A[51][51];
pair <int, int> results[2501];
bool isOne = false;

int main(){
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++)
        {
            cin >> A[i][j];
            if(A[i][j] == 1)
                isOne = true;
        }
    }
    if(!isOne)
        cout << 0 << endl;
    else{
        int res = -1;
        for(int i = 1; i<=n-1; i++){
            for(int j = 1; j<=m-1; j++)
            {
                if(A[i][j] != 0 && A[i+1][j] != 0 && A[i][j+1] != 0 && A[i+1][j+1] != 0)
                {
                    if(res==-1)
                        res = 1;
                    else
                        res++;
                    results[res].first = i;
                    results[res].second = j;
                }
            }
        }

        cout << res << endl;
        for(int i = 1;i<=res; i++)
            cout << results[i].first << " " << results[i].second << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    	}
	    }
	    vector<pair<int,int>>v;
	    fori(i,0,n){
	    	fori(j,0,m){
	    		if(a2[i][j]==1){
	    			sum=0;
	    			k=0;
	    			if(i>0 && j>0)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j-1]+a2[i-1][j-1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j<n-1)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i>0 && j<n-1)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j+1]+a2[i-1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j>0)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j-1]+a2[i+1][j-1];
	    			if(sum==4)
	    				k++;
	    		    if(k==0){
	    		    	cout<<-1;
	    		    	return 0;
	    		    }
	    		    else{
	    		    	v.pb(make_pair(i,j));
	    		    }
	    		}
	    	}
	    }
	    cout<<v.size()<<endl;
	    for(i=0;i<v.size();i++)
	    	cout<<v[i].first+1<<" "<<v[i].second+1<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    	}
	    }
	    vector<pair<int,int>>v;
	    fori(i,0,n){
	    	fori(j,0,m){
	    		if(a2[i][j]==1){
	    			sum=0;
	    			k=0;
	    			if(i>0 && j>0)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j-1]+a2[i-1][j-1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j<n-1)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i>0 && j<n-1)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j+1]+a2[i-1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j>0)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j-1]+a2[i+1][j-1];
	    			if(sum==4)
	    				k++;
	    		    if(k==0){
	    		    	cout<<-1;
	    		    	return 0;
	    		    }
	    		}
	    	}
	    }
		fori(i,0,n){
			fori(j,0,m){
				if(a2[i][j]==1){
					sum=0;
	    			if(i<n-1 && j<n-1)
					sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
					if(sum==4)
						v.pb(make_pair(i+1,j+1));
				}
			}
		}
		cout<<v.size()<<endl;
		for(i=0;i<v.size();i++)
			cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m],b2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    		b2[i][j]=0;
	    	}
	    }
	    vector<pair<int,int>>v;
		fori(i,0,n){
			fori(j,0,m){
				if(a2[i][j]==1){
					sum=0;
	    			if(i<n-1 && j<m-1)
						sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
					if(sum==4){
						v.pb(make_pair(i+1,j+1));
						b2[i][j]=1;
						b2[i+1][j]=1;
						b2[i][j+1]=1;
						b2[i+1][j+1]=1;
					}
				}
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(a2[i][j]!=b2[i][j]){
					cout<<-1;
					return 0;}
			}
		}
		cout<<v.size()<<endl;
		for(i=0;i<v.size();i++)
			cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    	}
	    }
	    vector<pair<int,int>>v;
	    fori(i,0,n){
	    	fori(j,0,m){
	    		if(a2[i][j]==1){
	    			sum=0;
	    			k=0;
	    			if(i>0 && j>0)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j-1]+a2[i-1][j-1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j<n-1)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i>0 && j<n-1)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j+1]+a2[i-1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j>0)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j-1]+a2[i+1][j-1];
	    			if(sum==4)
	    				k++;
	    		    if(k==0){
	    		    	cout<<-1;
	    		    	return 0;
	    		    }
	    		    else{
	    		    	v.pb(make_pair(i,j));
	    		    }
	    		}
	    	}
	    }
	    for(i=0;i<v.size();i++)
	    	cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    	}
	    }
	    vector<pair<int,int>>v;
	    fori(i,0,n){
	    	fori(j,0,m){
	    		if(a2[i][j]==1){
	    			sum=0;
	    			k=0;
	    			if(i>0 && j>0)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j-1]+a2[i-1][j-1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j<n-1)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i>0 && j<n-1)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j+1]+a2[i-1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j>0)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j-1]+a2[i+1][j-1];
	    			if(sum==4)
	    				k++;
	    		    if(k==0){
	    		    	cout<<-1;
	    		    	return 0;
	    		    }
	    		}
	    	}
	    }
		fori(i,0,n){
			fori(j,0,m){
				if(a2[i][j]==1){
					sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
					if(sum==4)
						v.pb(make_pair(i+1,j+1));
				}
			}
		}
		cout<<v.size()<<endl;
		for(i=0;i<v.size();i++)
			cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m],b2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    		b2[i][j]=0;
	    	}
	    }
	    vector<pair<int,int>>v;
		fori(i,0,n){
			fori(j,0,m){
				if(a2[i][j]==1){
					sum=0;
	    			if(i<n-1 && j<n-1)
						sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
					if(sum==4){
						v.pb(make_pair(i+1,j+1));
						b2[i][j]=1;
						b2[i+1][j]=1;
						b2[i][j+1]=1;
						b2[i+1][j+1]=1;
					}
				}
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(a2[i][j]!=b2[i][j]){
					cout<<-1;
					return 0;}
			}
		}
		cout<<v.size()<<endl;
		for(i=0;i<v.size();i++)
			cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define fori(i,j,n) for(int i=j;i<n;i++)
#define ford(i,j,n) for(int i=j-1;i>=n;i--)
ll a[N];
ll b[N];
ll c[N];
ll fq[N]={0};
string str[N];
bool mycmp(ll x,ll y){
    return (x>y);
}
int main(){
	ll T,TT=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//cin>>TT;
	for(T=1;T<=TT;T++){
	    ll n,i,j=0,l,r,k=1,m=0,ans=0,max_ele=INT_MIN,q,min_ele=INT_MAX,dig,sum=0,x=0,y=0,z=0,p=int(1e9+7);
	    string s,s1,s2,s3;
	    vector<pair<ll,ll>>vec1;
	    vector<pair<ll,pair<ll,ll>>>vec2;
	    cin>>n>>m;
	    ll a2[n][m];
	    fori(i,0,n){
	    	fori(j,0,m){
	    		cin>>a2[i][j];
	    	}
	    }
	    vector<pair<int,int>>v;
	    fori(i,0,n){
	    	fori(j,0,m){
	    		if(a2[i][j]==1){
	    			sum=0;
	    			k=0;
	    			if(i>0 && j>0)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j-1]+a2[i-1][j-1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j<n-1)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j+1]+a2[i+1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i>0 && j<n-1)
	    			sum=a2[i][j]+a2[i-1][j]+a2[i][j+1]+a2[i-1][j+1];
	    			if(sum==4)
	    				k++;
	    			sum=0;
	    			if(i<n-1 && j>0)
	    			sum=a2[i][j]+a2[i+1][j]+a2[i][j-1]+a2[i+1][j-1];
	    			if(sum==4)
	    				k++;
	    		    if(k==0){
	    		    	cout<<-1;
	    		    	return 0;
	    		    }
	    		    else{
	    		    	v.pb(make_pair(i,j));
	    		    }
	    		}
	    	}
	    }
	    cout<<v.size()<<endl;
	    for(i=0;i<v.size();i++)
	    	cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'

int main() {
  ios::sync_with_stdio(0); cin.tie(0);

  ll h,w;
  cin >> h >> w;
  vector<vector<int>> A(h, vector<int>(w));
  vector<vector<int>> B(h, vector<int>(w));
  for (auto& _r : A) for (auto& _a : _r) cin >> _a;

  vector<array<ll,2>> ans;
  for (int y = 0; y+1 < h; ++y) {
    for (int x = 0; x+1 < w; ++x) {
      if (A[y][x] == 1 && A[y][x+1] == 1 && A[y+1][x+1] == 1 && A[y+1][x] == 1) {
        ans.push_back({y,x});
        B[y][x] = 1;
        B[y+1][x] = 1;
        B[y+1][x+1] = 1;
        B[y][x+1] = 1;
      }
    }
  }
  if (A==B) {
    cout << ans.size() << endl;
    for (auto& [y,x] : ans) {
      cout << y+1 << " " << x+1 << endl;
    }
  } else {
    cout << -1 << endl;
  }

}


#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

int main () {
  ios::sync_with_stdio(0); cin.tie(0);

  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll h,w;
    cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w));
    for (auto& row : A) for (auto& x : row) cin >> x;
    const vector<pair<int,int>> dirs{{0,1}, {0,-1}, {1,0}, {-1,0}};
    bool good = true;
//    dbg(h,w,A);
    for (int y = 0; y < h && good; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x]) continue;
        int n_neighbor = 0;
        for (const auto& [dy,dx] : dirs) {
          int ty = y + dy;
          int tx = x + dx;
          if (ty >= 0 && ty < h && tx >= 0 && tx < w && A[ty][tx]) {
//            dbg(y,x, "neighbor: ", ty,tx);
            ++n_neighbor;
          }
        }
        if (n_neighbor <= 1) {
//          dbg(y,x, n_neighbor);
          good = false;
          break;
        }

        if (((y+1 < h && A[y+1][x]) || (y && A[y-1][x])) && (x+1 == w || !A[y][x+1]) && (x == 0 || !A[y][x-1])) {
          good = false;
          break;
        }

        if (((x+1 < w && A[y][x+1]) || (x && A[y][x-1])) && (y+1 == h || !A[y+1][x]) && (y == 0 || !A[y-1][x])) {
          good = false;
          break;
        }
      }
    }
    if (!good) {
      cout << -1 << endl;
      return 0;
    }
    vector<vector<bool>> visited(h, vector<bool>(w));
    vector<pair<int,int>> ans;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x] || visited[y][x]) continue;
        int fy = y;
        int fx = x;
        if (y+1 == h) --fy;
        if (x+1 == w) --fx;
        assert(fy+1 < h && fy+1 >= 0 && fx >= 0 && fx < w);
        if (!A[fy+1][fx]) --fy;
        assert(fy < h && fy >= 0 && fx+1 >= 0 && fx+1 < w);
        if (!A[fy][fx+1]) --fx;
        assert(fy+1 < h && fy+1 >= 0 && fx+1 >= 0 && fx+1 < w);
        if (!A[fy+1][fx+1]) {
          assert(fy-1 < h && fy-1 >= 0 && fx+1 >= 0 && fx+1 < w);
            assert(fy < h && fy >= 0 && fx >= 0 && fx < w);
          if (A[fy-1][fx] && A[fy][fx] && A[fy-1][fx+1] && A[fy][fx+1]) {
            --fy;
          } else {
            --fx;
          }
        }

        assert(fy < h && fy >= 0 && fx >= 0 && fx < w);
        assert(fy+1 < h && fy+1 >= 0 && fx+1 >= 0 && fx+1 < w);
//        dbg(fy,fx);

        ans.emplace_back(fy,fx);
        visited[fy][fx] = true;
        visited[fy][fx+1] = true;
        visited[fy+1][fx] = true;
        visited[fy+1][fx+1] = true;
//        dbg(visited);
      }
    }
    cout << ans.size() << endl;
    for (auto& [y,x] : ans) {
      cout << (y+1) << " " << (x+1) << endl;
    }
    vector<vector<int>> B(h, vector<int>(w));
    for (auto& [y,x] : ans) {
      assert(y+1 < h && x+1 < w);
      B[y][x] = 1;
      B[y][x+1] = 1;
      B[y+1][x] = 1;
      B[y+1][x+1] = 1;
    }
    assert(A == B);

  }
}


#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

int main () {
  ios::sync_with_stdio(0); cin.tie(0);

  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll h,w;
    cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w));
    for (auto& row : A) for (auto& x : row) cin >> x;
    const vector<pair<int,int>> dirs{{0,1}, {0,-1}, {1,0}, {-1,0}};
    vector<pair<int,int>> ans;
    for (int y = 0; y+1 < h; ++y) {
      for (int x = 0; x+1 < w; ++x) {
        if (!A[y][x]) continue;
        if (!A[y][x+1] || !A[y+1][x] || !A[y+1][x+1]) continue;
        ans.emplace_back(y,x);
      }
    }
    vector<vector<int>> B(h, vector<int>(w));
    for (auto& [y,x] : ans) {
      assert(y+1 < h && x+1 < w);
      B[y][x] = 1;
      B[y][x+1] = 1;
      B[y+1][x] = 1;
      B[y+1][x+1] = 1;
    }
    if (A == B) {
      cout << ans.size() << endl;
      for (auto& [y,x] : ans) {
        cout << (y+1) << " " << (x+1) << endl;
      }
    } else {
      cout << -1 << endl;
    }
  }
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'

int main() {
  ios::sync_with_stdio(0); cin.tie(0);

  ll h,w;
  cin >> h >> w;
  vector<vector<int>> A(h, vector<int>(w));
  vector<vector<int>> B(h, vector<int>(w));
  for (auto& _r : A) for (auto& _a : _r) cin >> _a;

  vector<array<ll,2>> ans;
  for (int y = 0; y+1 < h; ++y) {
    for (int x = 0; x+1 < w; ++x) {
      if (A[y][x] == 1 && A[y][x+1] == 1 && A[y+1][x+1] == 1 && A[y+1][x] == 1) {
        ans.push_back({y,x});
        B[y][x] = 1;
        B[y+1][x] = 1;
        B[y+1][x+1] = 1;
        B[y][x+1] = 1;
      }
    }
  }
  if (A==B) {
    cout << ans.size() << endl;
    for (auto& [y,x] : ans) {
      cout << x+1 << " " << y+1 << endl;
    }
  } else {
    cout << -1 << endl;
  }

}


#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

int main () {
  ios::sync_with_stdio(0); cin.tie(0);

  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll h,w;
    cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w));
    for (auto& row : A) for (auto& x : row) cin >> x;
    const vector<pair<int,int>> dirs{{0,1}, {0,-1}, {1,0}, {-1,0}};
    bool good = true;
//    dbg(h,w,A);
    for (int y = 0; y < h && good; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x]) continue;
        int n_neighbor = 0;
        for (const auto& [dy,dx] : dirs) {
          int ty = y + dy;
          int tx = x + dx;
          if (ty >= 0 && ty < h && tx >= 0 && tx < w && A[ty][tx]) {
//            dbg(y,x, "neighbor: ", ty,tx);
            ++n_neighbor;
          }
        }
        if (n_neighbor <= 1) {
//          dbg(y,x, n_neighbor);
          good = false;
          break;
        }

        if (((y+1 < h && A[y+1][x]) || (y && A[y-1][x])) && (x+1 == w || !A[y][x+1]) && (x == 0 || !A[y][x-1])) {
          good = false;
          break;
        }

        if (((x+1 < w && A[y][x+1]) || (x && A[y][x-1])) && (y+1 == h || !A[y+1][x]) && (y == 0 || !A[y-1][x])) {
          good = false;
          break;
        }
      }
    }
    if (!good) {
      cout << -1 << endl;
      return 0;
    }
    vector<vector<bool>> visited(h, vector<bool>(w));
    vector<pair<int,int>> ans;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x] || visited[y][x]) continue;
        int fy = y;
        int fx = x;
        if (y+1 == h) --fy;
        if (x+1 == w) --fx;
        assert(fy+1 < h && fy+1 >= 0 && fx >= 0 && fx < w);
        if (!A[fy+1][fx]) --fy;
        assert(fy < h && fy >= 0 && fx+1 >= 0 && fx+1 < w);
        if (!A[fy][fx+1]) --fx;
        assert(fy+1 < h && fy+1 >= 0 && fx+1 >= 0 && fx+1 < w);
        if (!A[fy+1][fx+1]) {
          assert(fy-1 < h && fy-1 >= 0 && fx+1 >= 0 && fx+1 < w);
            assert(fy < h && fy >= 0 && fx >= 0 && fx < w);
          if (A[fy-1][fx] && A[fy][fx] && A[fy-1][fx+1] && A[fy][fx+1]) {
            --fy;
          } else {
            --fx;
          }
        }

        assert(fy < h && fy >= 0 && fx >= 0 && fx < w);
        assert(fy+1 < h && fy+1 >= 0 && fx+1 >= 0 && fx+1 < w);
//        dbg(fy,fx);

        ans.emplace_back(fy,fx);
        visited[fy][fx] = true;
        visited[fy][fx+1] = true;
        visited[fy+1][fx] = true;
        visited[fy+1][fx+1] = true;
//        dbg(visited);
      }
    }
    cout << ans.size() << endl;
    for (auto& [y,x] : ans) {
      cout << (y+1) << " " << (x+1) << endl;
    }
    // vector<vector<int>> B(h, vector<int>(w));
    // for (auto& [y,x] : ans) {
    //   assert(y+1 < h && x+1 < w);
    //   B[y][x] = 1;
    //   B[y][x+1] = 1;
    //   B[y+1][x] = 1;
    //   B[y+1][x+1] = 1;
    // }
    // assert(A == B);

  }
}


#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

int main () {
  ios::sync_with_stdio(0); cin.tie(0);

  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll h,w;
    cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w));
    for (auto& row : A) for (auto& x : row) cin >> x;
    const vector<pair<int,int>> dirs{{0,1}, {0,-1}, {1,0}, {-1,0}};
    bool good = true;
//    dbg(h,w,A);
    for (int y = 0; y < h && good; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x]) continue;
        int n_neighbor = 0;
        for (const auto& [dy,dx] : dirs) {
          int ty = y + dy;
          int tx = x + dx;
          if (ty >= 0 && ty < h && tx >= 0 && tx < w && A[ty][tx]) {
//            dbg(y,x, "neighbor: ", ty,tx);
            ++n_neighbor;
          }
        }
        if (n_neighbor <= 1) {
//          dbg(y,x, n_neighbor);
          good = false;
          break;
        }
      }
    }
    if (!good) {
      cout << -1 << endl;
      return 0;
    }
    vector<vector<bool>> visited(h, vector<bool>(w));
    vector<pair<int,int>> ans;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x] || visited[y][x]) continue;
        int fy = y;
        int fx = x;
        if (y+1 == h) --fy;
        if (x+1 == w) --fx;
        assert(fy+1 < h && fy+1 >= 0 && fx >= 0 && fx < w);
        if (!A[fy+1][fx]) --fy;
        assert(fy < h && fy >= 0 && fx+1 >= 0 && fx+1 < w);
        if (!A[fy][fx+1]) --fx;
        assert(fy+1 < h && fy+1 >= 0 && fx+1 >= 0 && fx+1 < w);
        if (!A[fy+1][fx+1]) {
          assert(fy-1 < h && fy-1 >= 0 && fx+1 >= 0 && fx+1 < w);
            assert(fy < h && fy >= 0 && fx >= 0 && fx < w);
          if (A[fy-1][fx] && A[fy][fx] && A[fy-1][fx+1] && A[fy][fx+1]) {
            --fy;
          } else {
            --fx;
          }
        }

        assert(fy < h && fy >= 0 && fx >= 0 && fx < w);
        assert(fy+1 < h && fy+1 >= 0 && fx+1 >= 0 && fx+1 < w);
//        dbg(fy,fx);

        ans.emplace_back(fy,fx);
        visited[fy][fx] = true;
        visited[fy][fx+1] = true;
        visited[fy+1][fx] = true;
        visited[fy+1][fx+1] = true;
//        dbg(visited);
      }
    }
    cout << ans.size() << endl;
    for (auto& [y,x] : ans) {
      cout << (y+1) << " " << (x+1) << endl;
    }
  }
}


#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

int main () {
  ios::sync_with_stdio(0); cin.tie(0);

  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll h,w;
    cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w));
    for (auto& row : A) for (auto& x : row) cin >> x;
    const vector<pair<int,int>> dirs{{0,1}, {0,-1}, {1,0}, {-1,0}};
    bool good = true;
    for (int y = 0; y < h && good; ++y) {
      for (int x = 0; x < w; ++x) {
        if (!A[y][x]) continue;
        int n_neighbor = 0;
        for (const auto& [dy,dx] : dirs) {
          int ty = y + dy;
          int tx = x + dx;
          if (ty >= 0 && ty < h && tx >= 0 && tx < w && A[ty][tx]) {
//            dbg(y,x, "neighbor: ", ty,tx);
            ++n_neighbor;
          }
        }
        if (n_neighbor <= 1) {
//          dbg(y,x, n_neighbor);
          good = false;
          break;
        }

        if (((y+1 < h && A[y+1][x]) || (y && A[y-1][x])) && (x+1 == w || !A[y][x+1]) && (x == 0 || !A[y][x-1])) {
          good = false;
          break;
        }

        if (((x+1 < w && A[y][x+1]) || (x && A[y][x-1])) && (y+1 == h || !A[y+1][x]) && (y == 0 || !A[y-1][x])) {
          good = false;
          break;
        }
      }
    }
    if (!good) {
      cout << -1 << endl;
      return 0;
    }
    vector<pair<int,int>> ans;
    for (int y = 0; y+1 < h; ++y) {
      for (int x = 0; x+1 < w; ++x) {
        if (!A[y][x]) continue;
        if (!A[y][x+1] || !A[y+1][x] || !A[y+1][x+1]) continue;
        ans.emplace_back(y,x);
      }
    }
    cout << ans.size() << endl;
    for (auto& [y,x] : ans) {
      cout << (y+1) << " " << (x+1) << endl;
    }
    vector<vector<int>> B(h, vector<int>(w));
    for (auto& [y,x] : ans) {
      assert(y+1 < h && x+1 < w);
      B[y][x] = 1;
      B[y][x+1] = 1;
      B[y+1][x] = 1;
      B[y+1][x+1] = 1;
    }
    assert(A == B);

  }
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 55
int a[maxn][maxn],b[maxn][maxn],vis[maxn][maxn];
int p[maxn*100][2],ans;
bool check(int x,int y){
	if(a[x+1][y]==1&&a[x+1][y+1]==1&&a[x][y+1]==1)return true;
	if(a[x][y+1]==1&&a[x-1][y]==1&&a[x-1][y+1]==1)return true;
	if(a[x][y-1]==1&&a[x-1][y]==1&&a[x-1][y-1]==1)return true;
	if(a[x+1][y]==1&&a[x+1][y-1]==1&&a[x][y-1]==1)return true;
	return false;
}
void solve(int n,int m){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]==1&&i<n&&a[i+1][j]==1&&j<m&&a[i][j+1]==1){
				p[ans][0]=i;
				p[ans++][1]=j;
			}
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<ans;i++){
		cout<<p[i][0]<<" "<<p[i][1]<<endl;
	}
}
int main(){
	ios::sync_with_stdio(false);
	memset(a,0,sizeof(a));
	int n,m;
	while(cin>>n>>m){
		memset(b,0,sizeof(b));
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>a[i][j];
			}
		}
		bool flag=true;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(a[i][j]==1)
					if(!check(i,j)){
						flag=false;
						break;
					}
			}
		}
		if(flag){
			ans=0;
			memset(vis,0,sizeof(vis));
			solve(n,m);
		}else{
			cout<<"-1"<<endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#pragma GCC diagnostic warning "-std=c++11"

/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
***I_Love_Trench***/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) – To sort the given vector.

reverse(first_iterator, last_iterator) – To reverse a vector.

*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements

count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
which has a value not less than ‘x’.

upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than ‘x’.

arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) – It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{
    ll n,m,i,f=0,k=0,x=0,j,l=0;
    cin>>n>>m;
    ll a[n+5][m+5],b[3000],c[3000],p[n+5][m+5];
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=m; j++)
        {
            cin>>a[i][j];
            p[i][j]=a[i][j];
            if(a[i][j]==1)
                f=1;
        }
    }
    if(f==0)
        cout<<0<<endl;
    else
    {
        f=0;
        for(i=1; i<n; i++)
        {
            for(j=1; j<m; j++)
            {
                if(a[i][j]==1 && a[i][j+1]==1&& a[i+1][j]==1&&a[i+1][j+1]==1)
                {
                    b[k]=i;
                    c[k]=j;
                    k++;
                    f=1;
                    p[i][j]=0;
                    p[i][j+1]=0;
                    p[i+1][j]=0;
                    p[i+1][j+1]=0;

                }

            }
        }
        if(f==0)
        {
            cout<<-1<<endl;

        }
        else
        {
            f=0;
            for(i=1; i<=n; i++)
            {
                for(j=1; j<=m; j++)
                {
                    if(p[i][j]==1)
                        f=1;
                       // cout<<a[i][j]<<" ";
                }
               // cout<<endl;
            }
            if(f==1)
                cout<<-1<<endl;
            else
            {

                cout<<k<<endl;
                for(x=0; x<k; x++)
                    cout<<b[x]<<" "<<c[x]<<endl;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

#pragma GCC diagnostic warning "-std=c++11"

/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
***I_Love_Trench***/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) – To sort the given vector.

reverse(first_iterator, last_iterator) – To reverse a vector.

*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements

count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
which has a value not less than ‘x’.

upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than ‘x’.

arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) – It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{
    ll n,m,i,f=0,k=0,x=0,j,l=0;
    cin>>n>>m;
    ll a[n+5][m+5],b[100000],c[100000];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]==1)
                f=1;
        }
    }
    if(f==0)
        cout<<0<<endl;
    else
    {
        f=0;
        for(i=1;i<n;i++)
        {
            for(j=1;j<m;j++)
            {
                if(a[i][j]==1 && a[i][j+1]==1&& a[i+1][j]==1&&a[i+1][j+1]==1)
                {
                    b[k]=i;
                    c[k]=j;
                    k++;
                    f=1;
                }
            }
        }
        if(f==0)
            cout<<-1<<endl;
        else
        {
            cout<<k<<endl;
            for(x=0;x<k;x++)
                cout<<b[x]<<" "<<c[x]<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

#pragma GCC diagnostic warning "-std=c++11"

/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
***I_Love_Trench***/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) – To sort the given vector.

reverse(first_iterator, last_iterator) – To reverse a vector.

*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements

count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
which has a value not less than ‘x’.

upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than ‘x’.

arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) – It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{
    ll n,m,i,f=0,k=0,x=0,j,l=0;
    cin>>n>>m;
    ll a[n+5][m+5],b[1000000],c[1000000];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]==1)
                f=1;
        }
    }
    if(f==0)
        cout<<0<<endl;
    else
    {
        f=0;
        for(i=1;i<n;i++)
        {
            for(j=1;j<m;j++)
            {
                if(a[i][j]==1 && a[i][j+1]==1&& a[i+1][j]==1&&a[i+1][j+1]==1)
                {
                    b[k++]=i;
                    c[l++]=j;
                    f=1;
                }
            }
        }
        if(f==0)
            cout<<-1<<endl;
        else
        {
            cout<<k<<endl;
            for(x=0;x<k;x++)
                cout<<b[x]<<" "<<c[x]<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

#pragma GCC diagnostic warning "-std=c++11"

/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
***I_Love_Trench***/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) – To sort the given vector.

reverse(first_iterator, last_iterator) – To reverse a vector.

*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements

count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
which has a value not less than ‘x’.

upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than ‘x’.

arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) – It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{
    ll n,m,i,f=0,k=0,x=0,j,l=0;
    cin>>n>>m;
    ll a[n+5][m+5],b[100],c[100];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]==1)
                f=1;
        }
    }
    if(f==0)
        cout<<0<<endl;
    else
    {
        f=0;
        for(i=1;i<n;i++)
        {
            for(j=1;j<m;j++)
            {
                if(a[i][j]==1 && a[i][j+1]==1&& a[i+1][j]==1&&a[i+1][j+1]==1)
                {
                    b[k++]=i;
                    c[l++]=j;
                    f=1;
                }
            }
        }
        if(f==0)
            cout<<-1<<endl;
        else
        {
            cout<<k<<endl;
            for(x=0;x<k;x++)
                cout<<b[x]<<" "<<c[x]<<endl;
        }
    }

    return 0;
}