#include <bits/stdc++.h>
using namespace std;
char mp[1111][1111];
int flag[1111][1111];
int check(int x, int y) {
  int len = 0;
  while (mp[x + len][y] == '*' && mp[x][y + len] == '*' &&
         mp[x - len][y] == '*' && mp[x][y - len] == '*') {
    len++;
  }
  for (int i = 1; i <= len - 1; i++) {
    flag[x + i][y] = 1;
    flag[x - i][y] = 1;
    flag[x][y - i] = flag[x][y + i] = 1;
  }
  return len - 1;
}
struct node {
  int x, y, len;
} ans[1000200];
int cnt = 0;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%s", mp[i] + 1);
  }
  if (mp[1][1] == '*' || mp[1][m] == '*' || mp[n][m] == '*' ||
      mp[n][1] == '*') {
    printf("-1\n");
    return 0;
  }
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < m; j++) {
      if (mp[i][j] == '*') {
        int len = check(i, j);
        if (len != 0) {
          flag[i][j] = 1;
          ans[++cnt].x = i;
          ans[cnt].y = j;
          ans[cnt].len = len;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] == '*') {
        if (flag[i][j] == 0) {
          printf("-1\n");
          return 0;
        }
      }
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) {
    printf("%d %d %d\n", ans[i].x, ans[i].y, ans[i].len);
  }
  return 0;
}
