#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
int n, m, tot;
char s[N][N];
int len[N][N][4], sumx[N][N], sumy[N][N];
int ans[N * N][3];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> (s[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (s[i][j] == '*')
        len[i][j][0] = len[i][j - 1][0] + 1;
      else
        len[i][j][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = m; j; j--)
      if (s[i][j] == '*')
        len[i][j][1] = len[i][j + 1][1] + 1;
      else
        len[i][j][1] = 0;
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++)
      if (s[i][j] == '*')
        len[i][j][2] = len[i - 1][j][2] + 1;
      else
        len[i][j][2] = 0;
  for (int j = 1; j <= m; j++)
    for (int i = n; i; i--)
      if (s[i][j] == '*')
        len[i][j][3] = len[i + 1][j][3] + 1;
      else
        len[i][j][3] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int Min = INF;
      for (int k = 0; k < 4; k++) Min = min(Min, len[i][j][k]);
      if (Min <= 1) continue;
      sumx[i][j - Min + 1]++;
      sumx[i][j + Min]--;
      sumy[i - Min + 1][j]++;
      sumy[i + Min][j]--;
      ans[++tot][0] = i, ans[tot][1] = j, ans[tot][2] = Min;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) sumx[i][j] = (sumx[i][j] + sumx[i][j - 1]);
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++) sumy[i][j] = (sumy[i][j] + sumy[i - 1][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (s[i][j] == '*' && sumx[i][j] + sumy[i][j] <= 0) {
        cout << -1;
        return 0;
      }
  cout << tot << "\n";
  for (int i = 1; i <= tot; i++)
    cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] - 1 << "\n";
  return 0;
}
