#include <bits/stdc++.h>
using namespace std;
const int maxn = 59;
int tu[maxn][maxn];
int vi[maxn][maxn];
int n, m;
int judge(int x, int y) {
  if (y + 1 > m || x + 1 > n) return 0;
  if (x < 1 || y < 1) return 0;
  int yes = 0;
  if (tu[x][y] && tu[x][y + 1] && tu[x + 1][y] && tu[x + 1][y + 1]) yes = 1;
  if (yes) {
    vi[x][y] = 1;
    vi[x][y + 1] = 1;
    vi[x + 1][y + 1] = 1;
    vi[x + 1][y] = 1;
    return 1;
  }
  return 0;
}
void next(int& x, int& y) {
  while (1) {
    y++;
    if (y == (m + 1)) {
      y = 1;
      x++;
    }
    if (x >= n + 1) return;
    if (!vi[x][y]) break;
  }
}
vector<int> ans;
int dfs(int x, int y) {
  while (!tu[x][y]) {
    next(x, y);
  }
  if (x > n) return 1;
  if (tu[x][y]) {
    int a = 0, b = 0;
    if (judge(x - 1, y - 1)) {
      a = x - 1;
      b = y - 1;
    } else if (judge(x - 1, y)) {
      a = x - 1;
      b = y;
    } else if (judge(x, y - 1)) {
      a = x;
      b = y - 1;
    } else if (judge(x, y)) {
      a = x;
      b = y;
    } else
      return 0;
    ans.push_back(a);
    ans.push_back(b);
    next(x, y);
    return dfs(x, y);
  }
}
int main(void) {
  scanf("%d %d", &n, &m);
  memset(vi, 0, sizeof(vi));
  for (int i = 1; i <= n; i++)
    for (int d = 1; d <= m; d++) scanf("%d", &tu[i][d]);
  if (dfs(1, 1)) {
    int len = ans.size() - 1;
    printf("%d\n", (len + 1) / 2);
    for (int i = 0; i < len; i += 2) printf("%d %d\n", ans[i], ans[i + 1]);
  } else
    printf("-1\n");
  return 0;
}
