You are given two matrices A and B. Each matrix contains exactly n rows and m columns. Each element of A is either 0 or 1; each element of B is initially 0.

You may perform some operations with matrix B. During each operation, you choose any submatrix of B having size 2 × 2, and replace every element in the chosen submatrix with 1. In other words, you choose two integers x and y such that 1 ≤ x < n and 1 ≤ y < m, and then set B_{x, y}, B_{x, y + 1}, B_{x + 1, y} and B_{x + 1, y + 1} to 1.

Your goal is to make matrix B equal to matrix A. Two matrices A and B are equal if and only if every element of matrix A is equal to the corresponding element of matrix B.

Is it possible to make these matrices equal? If it is, you have to come up with a sequence of operations that makes B equal to A. Note that you don't have to minimize the number of operations.

Input

The first line contains two integers n and m (2 ≤ n, m ≤ 50).

Then n lines follow, each containing m integers. The j-th integer in the i-th line is A_{i, j}. Each integer is either 0 or 1.

Output

If it is impossible to make B equal to A, print one integer -1.

Otherwise, print any sequence of operations that transforms B into A in the following format: the first line should contain one integer k — the number of operations, and then k lines should follow, each line containing two integers x and y for the corresponding operation (set B_{x, y}, B_{x, y + 1}, B_{x + 1, y} and B_{x + 1, y + 1} to 1). The condition 0 ≤ k ≤ 2500 should hold.

Examples

Input


3 3
1 1 1
1 1 1
0 1 1


Output


3
1 1
1 2
2 2


Input


3 3
1 0 1
1 0 1
0 0 0


Output


-1


Input


3 2
0 0
0 0
0 0


Output


0

Note

The sequence of operations in the first example:

\begin{matrix} 0 & 0 & 0 & & 1 & 1 & 0 & & 1 & 1 & 1 & & 1 & 1 & 1 \\\ 0 & 0 & 0 & → & 1 & 1 & 0 & → & 1 & 1 & 1 & → & 1 & 1 & 1 \\\ 0 & 0 & 0 & & 0 & 0 & 0 & & 0 & 0 & 0 & & 0 & 1 & 1 \end{matrix} 
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;
 
  
public class A2 {  
 
	static class Reader 
    { 
        final private int BUFFER_SIZE = 1 << 16; 
        private DataInputStream din; 
        private byte[] buffer; 
        private int bufferPointer, bytesRead; 
  
        public Reader() 
        { 
            din = new DataInputStream(System.in); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public Reader(String file_name) throws IOException 
        { 
            din = new DataInputStream(new FileInputStream(file_name)); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public String readLine() throws IOException 
        { 
            byte[] buf = new byte[1000000]; // line length 
            int cnt = 0, c; 
            while ((c = read()) != -1) 
            { 
                if (c == '\n') 
                    break; 
                buf[cnt++] = (byte) c; 
            } 
            return new String(buf, 0, cnt); 
        } 
  
        public int nextInt() throws IOException 
        { 
            int ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do
            { 
                ret = ret * 10 + c - '0'; 
            }  while ((c = read()) >= '0' && c <= '9'); 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public long nextLong() throws IOException 
        { 
            long ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public double nextDouble() throws IOException 
        { 
            double ret = 0, div = 1; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
  
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
  
            if (c == '.') 
            { 
                while ((c = read()) >= '0' && c <= '9') 
                { 
                    ret += (c - '0') / (div *= 10); 
                } 
            } 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        private void fillBuffer() throws IOException 
        { 
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
            if (bytesRead == -1) 
                buffer[0] = -1; 
        } 
  
        private byte read() throws IOException 
        { 
            if (bufferPointer == bytesRead) 
                fillBuffer(); 
            return buffer[bufferPointer++]; 
        } 
  
        public void close() throws IOException 
        { 
            if (din == null) 
                return; 
            din.close(); 
        } 
    } 
 
    static void oracle(int graph[][], int dist[][], int V) 
    { 
        int i, j, k; 
  
        for (i = 1; i < V; i++) 
            for (j = 1; j < V; j++) 
                dist[i][j] = graph[i][j]; 
  
        for (k = 1; k < V; k++) 
        { 
            for (i = 1; i < V; i++) 
            { 
                for (j = 1; j < V; j++) 
                { 
                    if (dist[i][k] + dist[k][j] < dist[i][j]) 
                        dist[i][j] = dist[i][k] + dist[k][j]; 
                } 
            } 
        } 
    } 
 
    static long fast_pow(long base,long n,long M)
    {
        if(n==0)
           return 1;
        if(n==1)
        return base;
        long halfn=fast_pow(base,n/2,M);
        if(n%2==0)
            return ( halfn * halfn ) % M;
        else
            return ( ( ( halfn * halfn ) % M ) * base ) % M;
    }
 
    static long finextDoubleMMI_fermat(long n,int M)
    {
        return fast_pow(n,M-2,M);
    }
 
    static long nCrModPFermat(int n, int r, int p) 
    { 
        if (r == 0) 
            return 1; 
        long[] fac = new long[n+1]; 
        fac[0] = 1;           
        for (int i = 1 ;i <= n; i++) 
            fac[i] = fac[i-1] * i % p;       
        return (fac[n]* finextDoubleMMI_fermat(fac[r], p)% p * finextDoubleMMI_fermat(fac[n-r], p) % p) % p; 
    } 
 
    static void merge(int arr[], int l, int m, int r) 
    { 
        int n1 = m - l + 1; 
        int n2 = r - m; 
  
        int L[] = new int [n1]; 
        int R[] = new int [n2]; 
  
        for (int i=0; i<n1; ++i) 
            L[i] = arr[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = arr[m + 1+ j]; 
        int i = 0, j = 0; 
        
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                arr[k] = L[i]; 
                i++; 
            } 
            else
            { 
                arr[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
  
        while (i < n1) 
        { 
            arr[k] = L[i]; 
            i++; 
            k++; 
        } 
  
        while (j < n2) 
        { 
            arr[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
  
    static void sort(int arr[], int l, int r) 
    { 
        if (l < r) 
        { 
            int m = (l+r)/2; 
            sort(arr, l, m); 
            sort(arr , m+1, r); 
            merge(arr, l, m, r); 
        } 
    } 
 
    static void sort(int arr[]) 
    { 
        int l=0;
        int r=arr.length-1;
        if (l < r) 
        { 
            int m = (l+r)/2; 
            sort(arr, l, m); 
            sort(arr , m+1, r); 
            merge(arr, l, m, r); 
        } 
    } 
 
    static int[] arint(int n)throws IOException{
        int i;
        int a[]=new int[n];
        for(i=0;i<n;i++)
            a[i]=sc.nextInt();
        return a;
    }
 
 
    static long[] arlong(int n)throws IOException{
        int i;
        long a[]=new long[n];
        for(i=0;i<n;i++)
            a[i]=sc.nextLong();
        return a;
    }

    static long sum(long a){
    	long s=0;
    	while(a>0){
    		s+=a%10;
    		a/=10;
    	}
    	return s;
    }

    static int parity(int a[], int i){
    	int y=a[i];
    	int z=0;
    	while(y>0){
    		z+=y%2;
    		y/=2;
    	}
    	return z;
    }

    static long gcd(long a, long b){
        if(a%b==0)
            return b;
        if(b%a==0)
            return a;
        if(a>b)
            return gcd(a%b,b);
        return gcd(a,b%a);
    }

    static long p(long n) 
    { 
        long c=0;
        for (int i=1; i<=(int)(Math.sqrt(n)); i++) 
        { 
            if (n%i==0) 
            { 
                if (n/i == i) 
                    c++;
       
                else 
                    c+=2;
            } 
        } 
        return c;
    } 

    static Reader sc=new Reader(); 
    // static Scanner sc=new Scanner(System.in);
    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 
    public static void main(String args[])throws IOException{
    	int i,j;
        int n=sc.nextInt();
        int m=sc.nextInt();
        int a[][]=new int[n][m];
        int b[][]=new int[n][m];
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                a[i][j]=sc.nextInt();
            }
        }
        int x[][]=new int[m*n][2];
        // String y[]=new String[m*n];
        int c=0;
        int f=0;
        b:for(j=0;j<m-1;j++){
            for(i=0;i<n-1;i++){
                if(a[i][j]==1&&b[i][j]==0){
                    // y[c++]=(i+1)+" "+(j+1);
                    x[c][0]=i+1;
                    x[c++][1]=j+1;
                    // pw.println(y[c-1]);
                    // for(int ii=0;ii<n;ii++){
                    //     for(int jj=0;jj<m;jj++){
                    //         pw.print(b[ii][jj]+" ");
                    //     }
                    //     pw.println();
                    // }
                    b[i][j]=b[i][j+1]=b[i+1][j]=b[i+1][j+1]=1;
                }
                else if(a[i][j]==1&&a[i+1][j]==1&&a[i][j+1]==1&&a[i+1][j+1]==1)
                {
                    x[c][0]=i+1;
                    x[c++][1]=j+1;
                    b[i][j]=b[i][j+1]=b[i+1][j]=b[i+1][j+1]=1;    
                }
                // else if(a[i][j]==0&&b[i][j]==1){
                //     f=1;
                //     break b;
                // }
                // if(i==n-2&&a[i+1][j]==1)
                //     y[c++]=(i+1)+" "+(j+1);    
            }
            // if(a[n-1][j]==0&&a[n-1][j-1]==1&&(j>=2&&a[n-1][j-2]==0)){
            //     f=1;
            //     break;
            // }
            // if(a[n-1][j]==1&&a[n-1][j-1]==0){
            //     f=1;
            //     break;
            // }
        }

        for(i=0;i<n-1;i++){
            if(a[i][m-1]==1&&b[i][m-1]==0){
                x[c][0]=i+1;
                x[c++][1]=m-1;
                // pw.println(y[c-1]);
                    // for(int ii=0;ii<n;ii++){
                    //     for(int jj=0;jj<m;jj++){
                    //         pw.print(b[ii][jj]+" ");
                    //     }
                    //     pw.println();
                    // }
                b[i][m-1]=b[i+1][m-1]=b[i][m-2]=b[i+1][m-2]=1;

            }
        }
        for(j=0;j<m-1;j++){
            if(a[n-1][j]==1&&b[n-1][j]==0){
                // y[c++]=(n-1)+" "+(j);
                x[c][0]=n-1;
                x[c++][1]=j+1;
                // pw.println(y[c-1]);
                //     for(int ii=0;ii<n;ii++){
                //         for(int jj=0;jj<m;jj++){
                //             pw.print(b[ii][jj]+" ");
                //         }
                //         pw.println();
                //     }
                b[n-1][j]=b[n-1][j+1]=b[n-2][j]=b[n-2][j+1]=1;
            }
        }
        if(a[n-1][m-1]==1&&b[n-1][m-1]==0){
            // y[c++]=(n-1)+" "+(m-1);
            x[c][0]=n-1;
            x[c++][1]=m-1;
            // pw.println(y[c-1]);
            //         for(int ii=0;ii<n;ii++){
            //             for(int jj=0;jj<m;jj++){
            //                 pw.print(b[ii][jj]+" ");
            //             }
            //             pw.println();
            //         }
                b[n-1][m-1]=b[n-1][m-2]=b[n-2][m-1]=b[n-2][m-2]=1;
        }
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                if(a[i][j]!=b[i][j]){
                    f=1;
                    break;
                }
            }
        }
        // for(i=0;i<n;i++){
        //     for(j=0;j<m;j++){
        //         // pw.print(b[i][j]+" ");
        //     }
        //     // pw.println();
        // }

        // for(j=0;j<m;j++){
        //     if(a[0][j]==1&&a[1][j]==0){
        //         f=1;
        //         break;
        //     }
        //     else if(a[0][j]==0&&a[1][j]==1&&(n>2&&a[2][j]==0)){
        //         f=1;
        //         break;
        //     }
        //     else if(a[n-1][j]==1&&a[n-2][j]==0){
        //         f=1;
        //         break;
        //     }
        //     else if(a[n-1][j]==0&&a[n-2][j]==1&&(n>2&&a[n-3][j]==0)){
        //         f=1;
        //         break;
        //     }
        //     // if(a[n-2][j])
        // }
        // int a[]=new int[n];
        if(f==1){
            pw.println(-1);
        }
        else{
            pw.println(c);
            for(i=0;i<c;i++)
                pw.println(x[i][0]+" "+x[i][1]);
        }
        pw.close();
    }
}	




