#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const int N = 1005;
int lf[N][N], ri[N][N], up[N][N], down[N][N];
bool vis[N][N];
void solve() {
  int n, m;
  cin >> n >> m;
  string s[n + 1];
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) up[i][j] = up[i - 1][j];
    for (int j = 1; j <= m; ++j) {
      if (s[i - 1][j - 1] == '*')
        up[i][j]++;
      else
        up[i][j] = 0;
      lf[i][j] = lf[i][j - 1];
      if (s[i - 1][j - 1] == '*')
        lf[i][j]++;
      else
        lf[i][j] = 0;
    }
  }
  for (int i = n; i >= 1; --i) {
    for (int j = m; j >= 1; --j) down[i][j] = down[i + 1][j];
    for (int j = m; j >= 1; --j) {
      if (s[i - 1][j - 1] == '*')
        ++down[i][j];
      else
        down[i][j] = 0;
      ri[i][j] = ri[i][j + 1];
      if (s[i - 1][j - 1] == '*')
        ++ri[i][j];
      else
        ri[i][j] = 0;
    }
  }
  vector<vector<int>> ans;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int l = lf[i][j];
      int r = ri[i][j];
      int u = up[i][j];
      int d = down[i][j];
      int mn = min({l, r, u, d});
      if (mn > 1) {
        int k = mn;
        int l = j;
        while (k--) vis[i][l--] = true;
        k = mn;
        l = j;
        while (k--) vis[i][l++] = true;
        k = mn;
        u = i;
        while (k--) vis[u--][j] = true;
        k = mn;
        u = i;
        while (k--) vis[u++][j] = true;
        ans.push_back({i, j, mn - 1});
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i - 1][j - 1] == '*' && !vis[i][j]) {
        cout << -1 << '\n';
        return;
      }
    }
  }
  cout << ans.size() << '\n';
  for (auto &it : ans) {
    for (int x : it) cout << x << " ";
    cout << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t = 1;
  for (int i = 1; i <= t; ++i) solve();
}
