#include <bits/stdc++.h>
using namespace std;
const int N = 60;
vector<int> v;
int n, m, a[N][N], b[N][N];
int main() {
  int kq = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 1) kq++;
      b[i][j] = 0;
    }
  if (kq == 0) {
    cout << 0;
    return 0;
  }
  kq = 0;
  for (int i = 1; i <= n - 1; i++)
    for (int j = 1; j <= m - 1; j++) {
      if (a[i][j] == 1) {
        if (a[i + 1][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j + 1] == 1) {
          b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = 1;
          kq++;
          v.push_back(i);
          v.push_back(j);
        }
      }
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != b[i][j]) {
        cout << -1;
        return 0;
      }
    }
  cout << kq << endl;
  for (int i = 0; i <= v.size() - 1; i += 2)
    cout << v[i] << " " << v[i + 1] << endl;
  return 0;
}
