#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<int>> b(n, vector<int>(m));
  vector<pair<int, int>> sq;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j] == 1 and a[i + 1][j] == 1 and a[i + 1][j + 1] == 1 and
          a[i][j + 1] == 1) {
        b[i][j] = 1;
        b[i + 1][j] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j + 1] = 1;
        sq.push_back({i + 1, j + 1});
      }
    }
  }
  if (a != b) {
    cout << -1;
  } else {
    cout << sq.size() << '\n';
    for (auto i : sq) {
      cout << i.first << ' ' << i.second << '\n';
    }
  }
  return 0;
}
