#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < v.size(); i++) os << v[i] << " ";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (typename set<T>::iterator it = v.begin(); it != v.end(); it++)
    os << *it << " ";
}
const int mod = 1e9 + 7;
const int N = 1e3 + 5;
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
char g[N][N];
int f[N][N], h[N][N], d[N][N], s[N][N], val[N][N];
int sum[N][N], sum2[N][N], vis[N][N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = (0); i <= (n - 1); i++) {
    scanf("%s", g[i]);
    for (int j = (0); j <= (m - 1); j++) {
      if (g[i][j] == '*') {
        f[i][j] = 1;
      } else {
        f[i][j] = 0;
      }
      if (f[i][j] == 1) {
        if (j > 0) f[i][j] += f[i][j - 1];
      }
    }
    for (int j = (m - 1); j >= (0); j--) {
      if (g[i][j] == '*') {
        h[i][j] = 1;
      } else
        h[i][j] = 0;
      if (h[i][j]) h[i][j] += h[i][j + 1];
    }
  }
  for (int j = (0); j <= (m - 1); j++) {
    for (int i = (0); i <= (n - 1); i++) {
      if (g[i][j] == '*') {
        d[i][j] = 1;
      }
      if (d[i][j]) {
        if (i > 0) d[i][j] += d[i - 1][j];
      }
    }
    for (int i = (n - 1); i >= (0); i--) {
      if (g[i][j] == '*') {
        s[i][j] = 1;
      }
      if (s[i][j]) {
        s[i][j] += s[i + 1][j];
      }
    }
  }
  int tot = 0;
  for (int i = (0); i <= (n - 1); i++) {
    for (int j = (0); j <= (m - 1); j++) {
      if (g[i][j] != '*') continue;
      val[i][j] =
          min(min(f[i][j] - 1, h[i][j] - 1), min(s[i][j] - 1, d[i][j] - 1));
      if (val[i][j] != 0) {
        tot++;
        int w = val[i][j];
        sum[i][j - w]++;
        sum[i][j + w + 1]--;
        sum2[i - w][j]++;
        sum2[i + w + 1][j]--;
      }
    }
  }
  for (int i = (0); i <= (n - 1); i++) {
    int tmp = 0;
    for (int j = (0); j <= (m - 1); j++) {
      tmp += sum[i][j];
      if (tmp) {
        vis[i][j] = 1;
      }
    }
  }
  for (int j = (0); j <= (m - 1); j++) {
    int tmp = 0;
    for (int i = (0); i <= (n - 1); i++) {
      tmp += sum2[i][j];
      if (tmp) {
        vis[i][j] = 1;
      }
    }
  }
  for (int i = (0); i <= (n - 1); i++) {
    for (int j = (0); j <= (m - 1); j++) {
      if (g[i][j] == '*' && !vis[i][j]) {
        cout << "-1";
        return 0;
      }
    }
  }
  cout << tot << endl;
  for (int i = (0); i <= (n - 1); i++) {
    for (int j = (0); j <= (m - 1); j++) {
      if (val[i][j]) {
        cout << i + 1 << " " << j + 1 << " " << val[i][j] << "\n";
      }
    }
  }
  return 0;
}
