#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  long long a[n + 5][m + 5];
  long long b[n + 5][m + 5];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = 0;
    }
  }
  vector<pair<long long, long long> > ans;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < m - 1; j++) {
      if ((a[i][j] == 1) && (a[i][j + 1] == 1) && (a[i + 1][j] == 1) &&
          (a[i + 1][j + 1] == 1)) {
        b[i][j] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j] = 1;
        b[i + 1][j + 1] = 1;
        ans.push_back({i + 1, j + 1});
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j] != b[i][j]) {
        cout << "-1";
        return 0;
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto &x : ans) cout << x.first << " " << x.second << "\n";
}
