#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  int b[n][m];
  int zeros = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 0) zeros++;
      b[i][j] = 0;
    }
  }
  if (zeros == n * m)
    cout << 0;
  else {
    int operat = 0;
    vector<int> v;
    for (int i = 0; i + 1 < n; i++) {
      for (int j = 0; j + 1 < m; j++) {
        if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j] == 1 &&
            a[i + 1][j + 1] == 1) {
          operat++;
          v.push_back(i);
          v.push_back(j);
          b[i][j] = 1;
          b[i][j + 1] = 1;
          b[i + 1][j] = 1;
          b[i + 1][j + 1] = 1;
        }
      }
    }
    if (operat == 0)
      cout << -1;
    else if (operat > 0) {
      bool t = 1;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (a[i][j] != b[i][j]) {
            t = 0;
          }
        }
      }
      if (t) {
        cout << operat << endl;
        for (int i = 0; i < v.size() - 2; i += 2) {
          cout << v[i] + 1 << " " << v[i + 1] + 1 << endl;
        }
        cout << v[v.size() - 2] + 1 << " " << v[v.size() - 1] + 1;
      } else
        cout << -1;
    }
  }
  return 0;
}
