#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio;
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> a(n, vector<long long>(m, 0));
  vector<vector<long long>> b(n, vector<long long>(m, 0));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  vector<pair<long long, long long>> my;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < m - 1; j++) {
      if (a[i][j] == 1 && a[i + 1][j] == 1 && a[i][j + 1] == 1 &&
          a[i + 1][j + 1] == 1) {
        b[i][j] = 1;
        b[i + 1][j] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j + 1] = 1;
        my.push_back({i + 1, j + 1});
      }
    }
  }
  long long flag = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (b[i][j] != a[i][j]) {
        flag = 1;
        break;
      }
    }
  }
  if (flag)
    cout << -1 << "\n";
  else {
    cout << my.size() << "\n";
    for (long long i = 0; i < my.size(); i++)
      cout << my[i].first << " " << my[i].second << "\n";
  }
  return 0;
}
