#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m, 0));
  vector<vector<int>> b(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  vector<pair<int, int>> ans;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j + 1] == 1 &&
          a[i + 1][j] == 1) {
        ans.push_back(make_pair(i, j));
        b[i][j] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j + 1] = 1;
        b[i + 1][j] = 1;
      }
    }
  }
  bool flag = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != b[i][j]) {
        flag = false;
        i = n;
        break;
      }
    }
  }
  if (flag) {
    cout << ans.size() << endl;
    for (auto it = ans.begin(); it != ans.end(); it++) {
      cout << (*it).first + 1 << " " << (*it).second + 1 << endl;
    }
  } else
    cout << -1 << endl;
  return 0;
}
