#include <bits/stdc++.h>
using namespace std;
int A[55][56];
int B[55][56];
int n, m;
struct Node {
  int x, y;
};
Node res[3000];
int main() {
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &A[i][j]);
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= m - 1; j++) {
      if (A[i][j] != 0 && A[i + 1][j] != 0 && A[i][j + 1] != 0 &&
          A[i + 1][j + 1] != 0) {
        B[i][j] = B[i + 1][j] = B[i][j + 1] = B[i + 1][j + 1] = 1;
        res[ans].x = i;
        res[ans].y = j;
        ans++;
      }
    }
  }
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (A[i][j] != B[i][j]) {
        flag = 0;
        break;
      }
    }
  }
  if (flag) {
    printf("%d\n", ans);
    for (int i = 0; i < ans; i++) {
      printf("%d %d\n", res[i].x, res[i].y);
    }
  } else {
    printf("-1\n");
  }
  return 0;
}
