#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int mat[n + 2][m + 2];
  memset(mat, 0, sizeof mat);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> mat[i][j];
  }
  vector<pair<int, int>> ans;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mat[i][j] == 1 && mat[i + 1][j] == 1 && mat[i][j + 1] == 1 &&
          mat[i + 1][j + 1] == 1)
        ans.push_back({i, j});
    }
  }
  int a[n + 2][m + 2];
  memset(a, 0, sizeof a);
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i].first;
    int y = ans[i].second;
    a[x][y] = 1;
    a[x + 1][y] = 1;
    a[x][y + 1] = 1;
    a[x + 1][y + 1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != mat[i][j]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
