#include <bits/stdc++.h>
const long double pi = 2 * acos(0.0);
using namespace std;
long long n, m, a[55][55], b[55][55];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < m; ++j) cin >> a[i][j];
  long long cnt = 0;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < m; ++j)
      if (a[i][j] and a[i + 1][j] and a[i][j + 1] and a[i + 1][j + 1])
        ++cnt, v.push_back(make_pair(i + 1, j + 1)),
            b[i][j] = 1, b[i][j + 1] = 1, b[i + 1][j] = 1, b[i + 1][j + 1] = 1;
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < m; ++j)
      if (a[i][j] != b[i][j]) {
        cout << "-1\n";
        return 0;
      }
  cout << cnt << endl;
  for (long long i = 0; i < cnt; ++i)
    cout << v[i].first << " " << v[i].second << endl;
  return 0;
}
