#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k = 0;
  cin >> n >> m;
  int a[n][m];
  vector<int> c;
  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] * a[i + 1][j] * a[i][j + 1] * a[i + 1][j + 1] > 0) {
        a[i][j] = 2;
        a[i + 1][j] = 2;
        a[i + 1][j + 1] = 2;
        a[i][j + 1] = 2;
        c.push_back(i);
        c.push_back(j);
        k++;
      }
    }
  }
  int z = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1) {
        z++;
        break;
      }
    }
  }
  if (z != 0) {
    cout << -1;
  } else {
    cout << k << "\n";
    for (int i = 0; i < 2 * k; i += 2) {
      cout << c[i] + 1 << " " << c[i + 1] + 1 << "\n";
    }
  }
  return 0;
}
