#include <bits/stdc++.h>
using namespace std;
int n, m, dp[5][1005][1005];
char a[1005][1005], c[1005][1005];
struct my {
  int first, second, r;
};
vector<my> V;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j], c[i][j] = a[i][j];
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      dp[1][i][j] = (a[i - 1][j] != '*' ? 0 : dp[1][i - 1][j] + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[2][i][j] = (a[i][j - 1] != '*' ? 0 : dp[2][i][j - 1] + 1);
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = n; i >= 1; i--) {
      dp[3][i][j] = (a[i + 1][j] != '*' ? 0 : dp[3][i + 1][j] + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 1; j--) {
      dp[4][i][j] = (a[i][j + 1] != '*' ? 0 : dp[4][i][j + 1] + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != '*') continue;
      int mn = 2e9;
      for (int k = 1; k <= 4; k++) mn = min(mn, dp[k][i][j]);
      if (mn == 0) continue;
      V.push_back({i, j, mn});
      for (int l = 1; l <= mn; l++)
        c[i + l][j] = c[i - l][j] = c[i][j + l] = c[i][j - l] = c[i][j] = '.';
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (c[i][j] == '*') return cout << -1, 0;
  cout << V.size() << "\n";
  for (auto it : V) cout << it.first << " " << it.second << " " << it.r << "\n";
  return 0;
}
