#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m], b[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = 0;
    }
  }
  bool f = 1;
  vector<pair<int, int> > ans;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j] == 0) continue;
      if (a[i][j]) {
        for (int k = i; k <= i + 1 && k < n; k++) {
          for (int l = j; l <= j + 1 && l < m; l++) {
            if (!a[k][l]) {
              f = 0;
              break;
            }
          }
        }
        if (f) {
          ans.push_back(make_pair(i, j));
          for (int k = i; k <= i + 1 && k < n; k++) {
            for (int l = j; l <= j + 1 && l < m; l++) {
              b[k][l] = 1;
            }
          }
        } else {
          f = 1;
        }
      }
    }
  }
  f = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != b[i][j]) {
        f = 0;
        break;
      }
    }
    if (!f) break;
  }
  if (!f)
    cout << -1 << endl;
  else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }
  }
}
