#include <bits/stdc++.h>
using namespace std;
int n, m, a[55][55], b[55][55], l[5000], c[5000], k;
int main() {
  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] == 1 && a[i + 1][j] == 1 && a[i][j + 1] == 1 &&
          a[i + 1][j + 1] == 1) {
        l[++k] = i;
        c[k] = j;
        b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] != b[i][j]) {
        cout << -1;
        return 0;
      }
    }
  cout << k << '\n';
  for (int i = 1; i <= k; ++i) cout << l[i] << ' ' << c[i] << '\n';
  return 0;
}
