#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x, y, z;
} Node;
Node e[1000010];
char a[1010][1010];
int vis[1010][1010];
int main() {
  int i, j, k, n, m, d;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", a[i]);
  d = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] == '*') {
        k = 1;
        while (i - k >= 0 && a[i - k][j] == '*' && i + k < n &&
               a[i + k][j] == '*' && j - k >= 0 && a[i][j - k] == '*' &&
               j + k < m && a[i][j + k] == '*') {
          vis[i][j] = 1;
          vis[i - k][j] = 1;
          vis[i + k][j] = 1;
          vis[i][j - k] = 1;
          vis[i][j + k] = 1;
          k++;
        }
        k--;
        if (k > 0) {
          e[d].x = i + 1;
          e[d].y = j + 1;
          e[d].z = k;
          d++;
        }
      }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] == '*' && vis[i][j] == 0) {
        printf("-1\n");
        return 0;
      }
  printf("%d\n", d);
  for (i = 0; i < d; i++) printf("%d %d %d\n", e[i].x, e[i].y, e[i].z);
  return 0;
}
