#include <bits/stdc++.h>
using namespace std;
void print(vector<int> &A) {
  for (int i = 0; i < A.size(); i++) printf("%d ", A[i]);
  printf("\n");
}
void printm(vector<vector<int> > &m) {
  for (int i = 0; i < m.size(); i++) print(m[i]);
  printf("\n");
}
bool is_matrix_eq(vector<vector<int> > &A, vector<vector<int> > &B) {
  for (int i = 0; i < A.size(); i++)
    for (int j = 0; j < A[0].size(); j++)
      if (A[i][j] != B[i][j]) return false;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > A(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  vector<pair<int, int> > ans;
  int k = 0;
  vector<vector<int> > B(n, vector<int>(m, 0));
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; 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) {
        ans.push_back(make_pair(i + 1, j + 1));
        B[i][j] = 1;
        B[i + 1][j] = 1;
        B[i][j + 1] = 1;
        B[i + 1][j + 1] = 1;
        k++;
      }
    }
  }
  if (!is_matrix_eq(A, B))
    cout << -1 << endl;
  else {
    cout << k << endl;
    for (int i = 0; i < ans.size(); i++)
      cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
