#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, c = 0;
  cin >> n >> m;
  long long b[n][m], a[n][m], z[n][m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = 0;
      z[i][j] = 0;
    }
  }
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < m - 1; j++) {
      if (a[i][j] == 1 && a[i + 1][j] == 1 && a[i][j + 1] == 1 &&
          a[i + 1][j + 1] == 1) {
        b[i][j] = 1;
        b[i + 1][j] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j + 1] = 1;
        c++;
        z[i][j] = 1;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++)
      if (a[i][j] != b[i][j]) {
        cout << "-1";
        return 0;
      }
  }
  cout << c << endl;
  if (c != 0) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++)
        if (z[i][j] == 1) cout << i + 1 << " " << j + 1 << endl;
    }
  }
  return 0;
}
