#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, l, v[1005][1005];
char c[1005][1005];
struct s {
  int x, y, s1;
} c1;
vector<s> q;
void dfs(int x, int y) {
  int i, j, k = 0;
  for (i = 1;; i++) {
    if (c[i + x][y] != '*' || c[x - i][y] != '*' || c[x][y + i] != '*' ||
        c[x][y - i] != '*') {
      break;
    } else {
      v[i + x][y] = 1;
      v[x - i][y] = 1;
      v[x][y + i] = 1;
      v[x][y - i] = 1;
      v[x][y] = 1;
    }
  }
  if (i > 1) {
    c1.x = x;
    c1.y = y;
    c1.s1 = i - 1;
    q.push_back(c1);
  }
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == '*') {
        k++;
      }
    }
  }
  if (!k) {
    cout << 0;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (c[i][j] == '*') {
        dfs(i, j);
      }
    }
  }
  int y = 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (c[i][j] == '*' && !v[i][j]) {
        y = 0;
        break;
      }
    }
  }
  if (!q.size() || !y) {
    cout << -1;
    return 0;
  }
  cout << q.size() << "\n";
  for (i = 0; i < q.size(); i++) {
    cout << q[i].x << " " << q[i].y << " " << q[i].s1 << "\n";
  }
}
