#include <bits/stdc++.h>
using namespace std;
void solve(vector<string>& v, int n, int m) {
  vector<vector<int>> left(n, vector<int>(m, 0));
  vector<vector<int>> right(n, vector<int>(m, 0));
  vector<vector<int>> up(n, vector<int>(m, 0));
  vector<vector<int>> down(n, vector<int>(m, 0));
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i - 1][j] == '*') {
        up[i][j] = 1 + up[i - 1][j];
      }
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (v[i + 1][j] == '*') {
        down[i][j] = 1 + down[i + 1][j];
      }
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (v[i][j - 1] == '*') {
        left[i][j] = 1 + left[i][j - 1];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = m - 2; j >= 0; j--) {
      if (v[i][j + 1] == '*') {
        right[i][j] = 1 + right[i][j + 1];
      }
    }
  }
  vector<vector<char>> w(n, vector<char>(m, '.'));
  vector<vector<int>> ans;
  for (int i = 1; i + 1 < n; i++) {
    for (int j = 1; j + 1 < m; j++) {
      if (v[i][j] == '.') continue;
      int x = min({up[i][j], down[i][j], left[i][j], right[i][j]});
      if (x == 0) continue;
      w[i][j] = '*';
      for (int k = 1; k <= x; k++) {
        w[i - k][j] = '*';
        w[i + k][j] = '*';
        w[i][j - k] = '*';
        w[i][j + k] = '*';
      }
      ans.push_back({i + 1, j + 1, x});
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] != w[i][j]) {
        cout << -1 << endl;
        return;
      }
    }
  }
  cout << ans.size() << endl;
  for (auto& v : ans) {
    for (auto& x : v) {
      cout << x << " ";
    }
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    solve(v, n, m);
  }
}
