#include <bits/stdc++.h>
using namespace std;
const int dl[] = {-1, 0, 1, 0};
const int dc[] = {0, -1, 0, 1};
struct STARS {
  int X, Y, R;
};
STARS S;
long long N, M, i, j, K, cnt, k;
long long l1[1005][1005], l2[1005][1005];
long long c1[1005][1005], c2[1005][1005];
bool ok[1005][1005];
string c[1005];
vector<STARS> SOL;
int main() {
  cin >> N >> M;
  for (i = 1; i <= N; i++) {
    cin >> c[i];
    c[i] = '{' + c[i];
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= M; j++) {
      if (c[i][j] == '*') {
        c1[i][j] += c1[i][j - 1] + 1;
        l1[i][j] += l1[i - 1][j] + 1;
      } else {
        l1[i][j] = 0;
        c1[i][j] = 0;
      }
    }
  }
  for (i = N; i >= 1; i--) {
    for (j = M; j >= 1; j--) {
      if (c[i][j] == '*') {
        c2[i][j] += c2[i][j + 1] + 1;
        l2[i][j] += l2[i + 1][j] + 1;
      } else {
        l2[i][j] = 0;
        c2[i][j] = 0;
      }
    }
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= M; j++) {
      if (c[i][j] == '*') {
        K = min(l1[i][j], l2[i][j]);
        K = min(K, c1[i][j]);
        K = min(K, c2[i][j]);
        K--;
        if (K == 0) continue;
        ok[i][j] = true;
        for (cnt = 1; cnt <= K; cnt++) {
          ok[i][j + cnt] = ok[i][j - cnt] = true;
          ok[i - cnt][j] = ok[i + cnt][j] = true;
        }
        S.X = i;
        S.Y = j;
        S.R = K;
        SOL.push_back(S);
      }
    }
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= M; j++) {
      if (ok[i][j] == false && c[i][j] == '*') {
        cout << -1;
        return 0;
      }
    }
  }
  cout << SOL.size() << '\n';
  for (i = 0; i < SOL.size(); i++)
    cout << SOL[i].X << " " << SOL[i].Y << " " << SOL[i].R << '\n';
  return 0;
}
