#include <bits/stdc++.h>
using namespace std;
short n, m;
char a[1111][1111];
short kx[4] = {1, -1, 0, 0}, ky[4] = {0, 0, 1, -1};
bool vis[4][1001][1001];
short d[4][1001][1001];
bool sat;
short dfs(short z, short u, short v) {
  if (vis[z][u][v]) return d[z][u][v];
  vis[z][u][v] = true;
  if (a[u][v] == '*')
    d[z][u][v] = 1;
  else
    return 0;
  short uu = u + kx[z], vv = v + ky[z];
  if (uu > 0 && vv > 0 && uu <= n && vv <= m) d[z][u][v] += dfs(z, uu, vv);
  return d[z][u][v];
}
int g[1111][1111], h[1111][1111];
vector<short> d1, d2, d3;
bool kt() {
  short u, v, z;
  for (int i = 0, ii = d1.size(); i < ii; i++) {
    u = d1[i], v = d2[i], z = d3[i];
    g[u - z][v]++, g[u + z + 1][v]--;
    h[u][v - z]++, h[u][v + z + 1]--;
  }
  for (short i = 1; i <= n; i++)
    for (short j = 1; j <= m; j++) {
      g[i][j] += g[i - 1][j];
      h[i][j] += h[i][j - 1];
      u = g[i][j] + h[i][j];
      if (u == 0) {
        if (a[i][j] == '*') return true;
      } else if (a[i][j] == '.')
        return true;
    }
  return false;
}
int main() {
  scanf("%hd%hd", &n, &m);
  for (short i = 1; i <= n; i++)
    for (short j = 1; j <= m; j++) scanf(" %c", &a[i][j]);
  short tmp;
  for (short i = 1; i <= n; i++)
    for (short j = 1; j <= m; j++) {
      if (a[i][j] == '*')
        sat = true;
      else
        continue;
      tmp = m + n;
      for (short z = 0; z < 4; z++) tmp = min(tmp, dfs(z, i, j));
      tmp--;
      if (tmp > 0) d1.push_back(i), d2.push_back(j), d3.push_back(tmp);
    }
  if (sat) {
    if (d1.empty())
      puts("-1");
    else {
      if (kt())
        puts("-1");
      else {
        printf("%d\n", d1.size());
        for (int i = 0, ii = d1.size(); i < ii; i++)
          printf("%hd %hd %hd\n", d1[i], d2[i], d3[i]);
      }
    }
  } else
    puts("0");
}
