#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a, r;
  for (int i = 0; i < n; ++i) {
    a.emplace_back(m);
    for (int& x : a[i]) cin >> x;
    r.emplace_back(m, 0);
  }
  int s = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      if (a[i][j] && a[i][j + 1] && a[i + 1][j] && a[i + 1][j + 1]) {
        r[i][j] = 1;
        ++s;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (!a[i][j] || r[i][j]) continue;
      if (i > 0 && r[i - 1][j]) continue;
      if (j > 0 && r[i][j - 1]) continue;
      if (i > 0 && j > 0 && r[i - 1][j - 1]) continue;
      cout << "-1\n";
      return 0;
    }
  }
  cout << s << "\n";
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      if (r[i][j]) cout << i + 1 << " " << j + 1 << "\n";
    }
  }
  return 0;
}
