#include <bits/stdc++.h>
using namespace std;
char g[1010][1010];
int l[1010][1010], r[1010][1010], up[1010][1010], dn[1010][1010];
int jx[1010][1010], jy[1010][1010];
int n, m;
struct ans {
  int x, y;
  int len;
};
vector<ans> p;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", g[i] + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (g[i][j] == '*') {
        l[i][j] = l[i][j - 1] + 1;
        up[i][j] = up[i - 1][j] + 1;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (g[i][j] == '*') {
        r[i][j] = r[i][j + 1] + 1;
        dn[i][j] = dn[i + 1][j] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (g[i][j] == '*') {
        int len = 0x3f3f3f3f;
        len = min(min(l[i][j], r[i][j]), min(up[i][j], dn[i][j]));
        if (len > 1) {
          ans temp;
          temp.x = i;
          temp.y = j;
          temp.len = len - 1;
          p.push_back(temp);
          jx[i - len + 1][j]++;
          jx[i + len][j]--;
          jy[i][j - len + 1]++;
          jy[i][j + len]--;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      jx[i][j] += jx[i - 1][j];
      jy[i][j] += jy[i][j - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (g[i][j] == '*' && jx[i][j] == 0 && jy[i][j] == 0) {
        printf("-1\n");
        return 0;
      }
    }
  }
  int size = p.size();
  printf("%d\n", size);
  for (int i = 0; i < size; i++) {
    printf("%d %d %d\n", p[i].x, p[i].y, p[i].len);
  }
  return 0;
}
