#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][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 b[n][m];
  memset(b, 0, sizeof b);
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      bool v = a[i][j] & a[i + 1][j] & a[i + 1][j + 1] & a[i][j + 1];
      if (v) {
        b[i][j] = b[i + 1][j] = b[i + 1][j + 1] = b[i][j + 1] = 1;
        ans.push_back(make_pair(i + 1, j + 1));
      }
    }
  }
  bool v = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      v &= (b[i][j] == a[i][j]);
    }
  }
  if (v) {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
