#include <bits/stdc++.h>
using namespace std;
struct out {
  int x, y, z;
};
int n, m, mat[1010][1010], matr[1010][1010], matc[1010][1010];
vector<out> ans;
int check(int i, int j) {
  int d = 1;
  while (i + d < n && i - d >= 0 && j + d < m && j - d >= 0) {
    if (!mat[i + d][j] && !mat[i][j + d] && !mat[i - d][j] && !mat[i][j - d])
      ++d;
    else
      break;
  }
  return d - 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      char x;
      cin >> x;
      mat[i][j] = (x == '.');
    }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (mat[i][j]) continue;
      int sz = check(i, j);
      if (!sz) continue;
      ++matr[i][j - sz];
      ++matc[j][i - sz];
      --matr[i][j + sz + 1];
      --matc[j][i + sz + 1];
      out o = {i + 1, j + 1, sz};
      ans.push_back(o);
    }
  for (int i = 0; i < n; ++i) {
    int p = 0;
    for (int j = 0; j < m; ++j) {
      p += matr[i][j];
      mat[i][j] += p;
    }
  }
  for (int j = 0; j < m; ++j) {
    int p = 0;
    for (int i = 0; i < n; ++i) {
      p += matc[j][i];
      mat[i][j] += p;
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (!mat[i][j]) {
        cout << -1;
        return 0;
      }
    }
  cout << ans.size() << endl;
  for (auto x : ans) cout << x.x << ' ' << x.y << ' ' << x.z << endl;
  return 0;
}
