#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') f = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = (x << 1) + (x << 3) + (op ^ 48);
    op = getchar();
  }
  return x * f;
}
int n, m, a[100][100], b[100][100], c[100][100], ans;
int main() {
  n = read();
  m = read();
  if (n < 2 || m < 2) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) a[i][j] = read();
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j) {
      if (a[i][j] && !b[i][j]) {
        ans++;
        c[i][j] = 1;
        if (!a[i + 1][j + 1]) {
          cout << -1;
          return 0;
        } else
          b[i + 1][j + 1] = 1;
        if (!a[i + 1][j]) {
          cout << -1;
          return 0;
        } else
          b[i + 1][j] = 1;
        if (!a[i][j + 1]) {
          cout << -1;
          return 0;
        } else
          b[i][j + 1] = 1;
      }
      if (a[i][j] && b[i][j]) {
        if (a[i + 1][j + 1] && a[i][j + 1] && a[i + 1][j])
          ans++, b[i + 1][j + 1] = b[i][j + 1] = b[i + 1][j] = c[i][j] = 1;
      }
    }
  for (int i = 1; i <= n; ++i)
    if (b[i][m] != a[i][m]) {
      cout << -1;
      return 0;
    }
  for (int i = 1; i <= m; ++i)
    if (b[n][i] != a[n][i]) {
      cout << -1;
      return 0;
    }
  cout << ans << endl;
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j)
      if (c[i][j]) cout << i << ' ' << j << endl;
}
