#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << '\n';
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
const int N = 5e1 + 7;
int n, m, a[N][N], b[N][N];
vector<pair<int, int> > v;
bool check(int a, int b, int c, int d) {
  return a == 1 && b == 1 && c == 1 && d == 1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> m;
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= m - 1; j++) cin >> a[i][j];
  for (int i = 0; i <= n - 2; i++)
    for (int j = 0; j <= m - 2; j++) {
      if (check(a[i][j], a[i + 1][j], a[i][j + 1], a[i + 1][j + 1])) {
        b[i][j] = b[i + 1][j] = b[i][j + 1] = b[i + 1][j + 1] = 1;
        v.push_back(make_pair(i + 1, j + 1));
      }
    }
  bool valid = true;
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= m - 1; j++)
      if (a[i][j] != b[i][j]) valid = false;
  if (valid) {
    cout << v.size() << '\n';
    for (auto i : v) cout << i.first << " " << i.second << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}
