#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n, m;
char mp[maxn][maxn];
bool vst[maxn][maxn] = {0};
int ans[maxn][maxn] = {0};
bool judge() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] == '*' && vst[i][j] == 0) return false;
    }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> mp[i][j];
    }
  int len;
  int cnt = 0;
  for (int i = 2; i < n; i++)
    for (int j = 2; j < m; j++) {
      if (mp[i][j] != '*') continue;
      len = 1;
      while (mp[i + len][j] == '*' && mp[i - len][j] == '*' &&
             mp[i][j - len] == '*' && mp[i][j + len] == '*') {
        vst[i + len][j] = vst[i - len][j] = vst[i][j - len] = vst[i][j + len] =
            1;
        len++;
      }
      if (len > 1) {
        if (ans[i][j] == 0) cnt++, vst[i][j] = 1;
        ans[i][j] = max(ans[i][j], len - 1);
      }
    }
  if (!judge()) {
    printf("-1");
    return 0;
  }
  printf("%d\n", cnt);
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < m; j++) {
      if (ans[i][j]) {
        printf("%d %d %d\n", i, j, ans[i][j]);
      }
    }
  }
  return 0;
}
