#include <bits/stdc++.h>
using namespace std;
int64_t inf = 1000 * 1000 * 1000;
int64_t inf64 = inf * inf;
int64_t mod = 228228227;
int64_t nll = 0;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr << fixed << setprecision(8);
  srand(time(0));
  auto START_TIME = chrono::high_resolution_clock::now();
  int32_t n, m;
  cin >> n >> m;
  vector<vector<int32_t> > a(n, vector<int32_t>(m, 0)),
      b(n, vector<int32_t>(m, 0));
  for (int32_t i = 0; i < n; ++i) {
    for (int32_t j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  vector<pair<int32_t, int32_t> > ans;
  for (int32_t i = 0; i < n - 1; ++i) {
    for (int32_t 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) {
        ans.emplace_back(i + 1, j + 1);
        b[i][j] = 1;
        b[i + 1][j + 1] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j] = 1;
      }
    }
  }
  for (int32_t i = 0; i < n; ++i) {
    for (int32_t j = 0; j < m; ++j) {
      if (a[i][j] != b[i][j]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans.size() << endl;
  for (auto &c : ans) cout << c.first << " " << c.second << endl;
  cerr << endl
       << chrono::duration<long double>(chrono::high_resolution_clock::now() -
                                        START_TIME)
              .count()
       << " sec.";
}
