#include <bits/stdc++.h>
using namespace std;
bool a[55][55], b[55][55], ans[55][55];
int n, m, ans_cnt;
int main() {
  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 - 1; i++)
    for (int j = 1; j <= m - 1; j++)
      if (a[i][j] && a[i + 1][j] && a[i][j + 1] && a[i + 1][j + 1]) {
        ans[i][j] = true;
        ans_cnt++;
        b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = true;
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] != b[i][j]) {
        cout << -1;
        return 0;
      }
  cout << ans_cnt << '\n';
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (ans[i][j]) cout << i << ' ' << j << '\n';
  return 0;
}
