#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
bool a[N][N], b[N][N];
vector<tuple<int, int, int> > ans;
void dfs(int i, int j) {
  if (!a[i - 1][j] || !a[i + 1][j] || !a[i][j - 1] || !a[i][j + 1]) return;
  b[i][j] = true;
  tuple<int, int, int> res;
  int l = 0;
  while (a[i - l - 1][j] && a[i + l + 1][j] && a[i][j - l - 1] &&
         a[i][j + l + 1]) {
    b[i - l - 1][j] = true;
    b[i + l + 1][j] = true;
    b[i][j - l - 1] = true;
    b[i][j + l + 1] = true;
    l++;
  }
  res = {i, j, l};
  ans.push_back(res);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j < m + 1; j++) {
      a[i][j] = false;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char cur;
      cin >> cur;
      if (cur == '*') a[i][j] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j]) dfs(i, j);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] && !b[i][j]) {
        cout << "-1";
        return 0;
      }
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++)
    cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i])
         << "\n";
}
