#include <bits/stdc++.h>
using namespace std;
char ch[1005][1005];
bool vis[1005][1005];
struct pot {
  int id_x;
  int id_y;
  int len;
};
int main() {
  int n, m;
  queue<struct pot> pq;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%s", ch[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ch[i][j] == '*') {
        vis[i][j] = 0;
      } else {
        vis[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ch[i][j] == '*') {
        int tot = 1;
        while (i - tot >= 0 && i + tot < n && j - tot >= 0 && j + tot < m &&
               ch[i + tot][j] == ch[i - tot][j] &&
               ch[i][j + tot] == ch[i][j - tot] && ch[i + tot][j] == '*' &&
               ch[i][j + tot] == '*') {
          vis[i][j + tot] = vis[i][j - tot] = vis[i + tot][j] =
              vis[i - tot][j] = 1;
          tot++;
        }
        if (tot > 1) {
          vis[i][j] = 1;
          struct pot aa;
          aa.id_x = i + 1;
          aa.id_y = j + 1;
          aa.len = (tot - 1);
          pq.push(aa);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!vis[i][j]) {
        printf("-1\n");
        return 0;
      }
    }
  }
  printf("%d\n", pq.size());
  while (!pq.empty()) {
    struct pot bb = pq.front();
    pq.pop();
    printf("%d %d %d\n", bb.id_x, bb.id_y, bb.len);
  }
  return 0;
}
