#include <bits/stdc++.h>
using namespace std;
bool a[55][55], b[55][55] = {{0}};
pair<int, int> rec[2510];
int cnt = 0;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (a[i][j] && a[i + 1][j] && a[i][j + 1] && a[i + 1][j + 1]) {
        rec[cnt++] = {i, j};
        b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = 1;
      }
    }
  }
  bool flag = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] != b[i][j]) flag = 1;
    }
  }
  if (flag)
    printf("-1\n");
  else {
    printf("%d\n", cnt);
    for (int i = 0; i < cnt; ++i) {
      printf("%d %d\n", rec[i].first, rec[i].second);
    }
  }
  return 0;
}
