#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int maxs = 3e5 + 5;
const int inf = 1e9;
const int mod = 1e9 + 7;
char a[maxn][maxn];
int vis[maxn][maxn];
int dp[maxn][maxn][5];
int dp1[maxn][maxn];
struct node {
  int x, y, z;
  node(int p, int q, int r) { x = p, y = q, z = r; }
};
vector<node> ans;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] + 1;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') {
        dp[i][j][1] = (a[i][j - 1] == '*' ? dp[i][j - 1][1] + 1 : 1);
        dp[i][j][2] = (a[i - 1][j] == '*' ? dp[i - 1][j][2] + 1 : 1);
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (a[i][j] == '*') {
        dp[i][j][3] = (a[i][j + 1] == '*' ? dp[i][j + 1][3] + 1 : 1);
        dp[i][j][4] = (a[i + 1][j] == '*' ? dp[i + 1][j][4] + 1 : 1);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') {
        dp1[i][j] = min(min(dp[i - 1][j][2], dp[i][j - 1][1]),
                        min(dp[i][j + 1][3], dp[i + 1][j][4]));
      }
    }
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*' && dp1[i][j]) {
        ans.push_back(node(i, j, dp1[i][j]));
        for (int pr = dp1[i][j]; pr >= 1; pr--) {
          vis[i - pr][j] = 1;
          vis[i + pr][j] = 1;
          vis[i][pr + j] = 1;
          vis[i][j - pr] = 1;
        }
        vis[i][j] = 1;
      }
    }
  }
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*' && !vis[i][j]) {
        flag = 0;
        break;
      }
    }
  }
  if (flag) {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].x << " " << ans[i].y << " " << ans[i].z << "\n";
    }
  } else
    cout << -1 << "\n";
}
