#include <bits/stdc++.h>
using namespace std;
const int NN = 55;
int a[NN][NN], flag[NN][NN];
vector<pair<int, int>> ans;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (a[i][j] && a[i + 1][j] && a[i][j + 1] && a[i + 1][j + 1]) {
        ans.push_back({i, j});
        flag[i][j] = 1;
        flag[i + 1][j] = 1;
        flag[i][j + 1] = 1;
        flag[i + 1][j + 1] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] && !flag[i][j]) {
        puts("-1");
        return 0;
      }
    }
  }
  cout << ans.size() << endl;
  for (auto u : ans) {
    cout << u.first << " " << u.second << endl;
  }
  return 0;
}
