#include <bits/stdc++.h>
using namespace std;
int a[51][51];
pair<int, int> mem[51][51];
bool isValid(int i, int j, int n, int m) {
  return i >= 0 && i < n && j >= 0 && j < m;
}
bool isQuad(pair<int, int> w, pair<int, int> x, pair<int, int> y,
            pair<int, int> z, int n, int m) {
  return isValid(w.first, w.second, n, m) && isValid(x.first, x.second, n, m) &&
         isValid(y.first, y.second, n, m) && isValid(z.first, z.second, n, m) &&
         a[w.first][w.second] && a[x.first][x.second] && a[y.first][y.second] &&
         a[z.first][z.second];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, tot = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j]) {
        tot++;
        if (isQuad({i, j}, {i + 1, j}, {i + 1, j + 1}, {i, j + 1}, n, m)) {
          mem[i][j] = {i + 1, j + 1};
        } else if (isQuad({i, j}, {i, j - 1}, {i + 1, j}, {i + 1, j - 1}, n,
                          m)) {
          mem[i][j] = {i + 1, j};
        } else if (isQuad({i, j}, {i - 1, j}, {i - 1, j + 1}, {i, j + 1}, n,
                          m)) {
          mem[i][j] = {i, j + 1};
        } else if (isQuad({i, j}, {i, j - 1}, {i - 1, j}, {i - 1, j - 1}, n,
                          m)) {
          mem[i][j] = {i, j};
        } else {
          cout << -1 << "\n";
          return 0;
        }
      }
    }
  }
  cout << tot << "\n";
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (a[i][j]) cout << mem[i][j].first << " " << mem[i][j].second << "\n";
}
