#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, t;
  scanf("%d %d", &n, &m);
  bool a[n][m], fail = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &t);
      if (t == 0) {
        a[i][j] = false;
      } else {
        a[i][j] = true;
      }
    }
  }
  vector<int> x, y;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!a[i][j]) {
        continue;
      }
      bool aaa = false;
      for (int k = -1; k < 1; k++) {
        for (int l = -1; l < 1; l++) {
          if (i + k < 0 || i + k + 1 >= n || j + l < 0 || j + l + 1 >= m ||
              aaa) {
            continue;
          }
          bool b = a[i + k][j + l] && a[i + k][j + l + 1] &&
                   a[i + k + 1][j + l] && a[i + k + 1][j + l + 1];
          if (b) {
            x.push_back(i + k);
            y.push_back(j + l);
            aaa = true;
          }
        }
      }
      if (!aaa) {
        fail = true;
      }
    }
  }
  if (fail) {
    printf("-1\n");
  } else {
    printf("%d\n", x.size());
    for (int i = 0; i < x.size(); i++) {
      printf("%d %d\n", x[i] + 1, y[i] + 1);
    }
  }
}
