#include <bits/stdc++.h>
int a[50][50], b[50][50], res[2500][2];
int eq(int n, int m) {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++)
      if (a[i][j] != b[i][j]) return 0;
  }
  return 1;
}
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int in = 0;
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < m - 1; j++) {
      if (a[i][j] && a[i + 1][j] && a[i][j + 1] && a[i + 1][j + 1]) {
        b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = 1;
        res[in][0] = i;
        res[in][1] = j;
        in++;
      }
    }
  }
  if (eq(n, m)) {
    printf("%d\n", in);
    for (i = 0; i < in; i++) printf("%d %d\n", res[i][0] + 1, res[i][1] + 1);
  } else {
    printf("-1\n");
  }
  return 0;
}
