#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<long int> a[n + 1], b[n + 1];
  vector<pair<int, int> > v;
  for (int i = 0; i <= n; i++) a[i].resize(m + 1), b[i].resize(m + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  }
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= m - 1; j++) {
      if (a[i][j + 1] == 1 && a[i + 1][j] == 1 && a[i + 1][j + 1] == 1 &&
          a[i][j] == 1) {
        v.push_back(make_pair(i, j));
        b[i][j + 1] = 1;
        b[i][j] = 1;
        b[i + 1][j] = 1;
        b[i + 1][j + 1] = 1;
      }
    }
  }
  int ct = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != b[i][j]) ct = 0;
    }
  }
  if (ct == 0)
    cout << -1;
  else {
    cout << v.size() << "\n";
    for (int i = 0; i < v.size(); i++)
      cout << v[i].first << " " << v[i].second << "\n";
  }
}
