#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 100;
const int md = 1000000007;
priority_queue<int, vector<int>, greater<int> > pq;
bool compare(pair<int, int> &a, pair<int, int> &b) { return a.first > b.first; }
int main() {
  int n, m, arr[60][60], ans[60][60] = {};
  bool sama = true;
  vector<pair<int, int> > path;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i += 1)
    for (int j = 0; j < m; j += 1) scanf("%d", &arr[i][j]);
  for (int i = 0; i < n - 1; i += 1) {
    for (int j = 0; j < m - 1; j += 1) {
      if (arr[i][j] + arr[i + 1][j] + arr[i][j + 1] + arr[i + 1][j + 1] == 4) {
        path.push_back(make_pair(i, j));
        ans[i][j] = ans[i + 1][j] = ans[i][j + 1] = ans[i + 1][j + 1] = 1;
      }
    }
  }
  for (int i = 0; i < n; i += 1) {
    for (int j = 0; j < m; j += 1)
      if (arr[i][j] != ans[i][j]) sama = false;
  }
  if (sama) {
    printf("%d\n", path.size());
    for (int i = 0; i < path.size(); i += 1)
      printf("%d %d\n", path[i].first + 1, path[i].second + 1);
  } else
    printf("-1\n");
}
