#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn][maxn];
int b[maxn][maxn] = {0};
int main() {
  multimap<int, int> p;
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j]) ans++;
    }
  }
  if (!ans) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int 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) {
        p.insert(make_pair(i + 1, j + 1));
        b[i][j] = 1;
        b[i + 1][j] = 1;
        b[i][j + 1] = 1;
        b[i + 1][j + 1] = 1;
      }
    }
  }
  int flag = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != b[i][j]) {
        flag = 1;
        break;
      }
    }
  }
  if (flag) {
    cout << "-1" << endl;
    return 0;
  }
  cout << p.size() << endl;
  multimap<int, int>::iterator it;
  for (it = p.begin(); it != p.end(); it++) {
    cout << it->first << " " << it->second << endl;
  }
  return 0;
}
