#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn][maxn], b[maxn][maxn];
int vis[maxn][maxn];
vector<pair<int, int> > ans;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (a[i + 1][j + 1] == 1 && a[i][j] == 1 && a[i + 1][j] == 1 &&
          a[i][j + 1] == 1) {
        ans.push_back(make_pair(i, j));
      }
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i].first;
    int y = ans[i].second;
    b[x][y] = 1;
    b[x + 1][y + 1] = 1;
    b[x + 1][y] = 1;
    b[x][y + 1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (b[i][j] != a[i][j]) {
        printf("-1\n");
        return 0;
      }
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
