#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > v;
  int a[1000][1000], b[1000][1000];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int flag = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j] == 1 or a[i + 1][j] == 1 or a[i][j + 1] == 1 or
          a[i + 1][j + 1] == 1) {
        flag = 1;
      }
      if (a[i][j] == 1 and a[i + 1][j] == 1 and a[i][j + 1] == 1 and
          a[i + 1][j + 1] == 1) {
        b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = 1;
        v.push_back(make_pair(i + 1, j + 1));
      }
    }
  }
  if (v.size() == 0 and flag == 1) {
    cout << -1 << endl;
    return 0;
  } else if (v.size() == 0 and flag == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != b[i][j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}
