#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
bool tb[N][N];
bool vst[N][N];
int st[N][N], V[N][N], H[N][N];
int n, m;
vector<pair<int, int> > v;
inline void complete() {
  int mm[N];
  for (int i = int(1); i < int(n + 1); i++) {
    memset(mm, 0, sizeof(mm));
    for (int j = int(1); j < int(m + 1); j++)
      if (tb[i][j]) {
        mm[j] = mm[j - 1] + 1;
        st[i][j] = min(st[i][j], mm[j] - 1);
      }
  }
  for (int i = int(1); i < int(n + 1); i++) {
    memset(mm, 0, sizeof(mm));
    for (int j = int(m + 1 - 1); j >= int(1); j--)
      if (tb[i][j]) {
        mm[j] = mm[j + 1] + 1;
        st[i][j] = min(st[i][j], mm[j] - 1);
      }
  }
  for (int j = int(1); j < int(m + 1); j++) {
    memset(mm, 0, sizeof(mm));
    for (int i = int(1); i < int(n + 1); i++)
      if (tb[i][j]) {
        mm[i] = mm[i - 1] + 1;
        st[i][j] = min(st[i][j], mm[i] - 1);
      }
  }
  for (int j = int(1); j < int(m + 1); j++) {
    memset(mm, 0, sizeof(mm));
    for (int i = int(n + 1 - 1); i >= int(1); i--)
      if (tb[i][j]) {
        mm[i] = mm[i + 1] + 1;
        st[i][j] = min(st[i][j], mm[i] - 1);
      }
  }
}
inline void solve() {
  memset(V, 0, sizeof(V));
  memset(H, 0, sizeof(H));
  memset(vst, false, sizeof(vst));
  for (int i = int(1); i < int(n + 1); i++)
    for (int j = int(1); j < int(m + 1); j++)
      if (tb[i][j] && st[i][j]) {
        v.push_back(make_pair(i, j));
        V[i - st[i][j]][j]++;
        V[i + st[i][j] + 1][j]--;
        H[i][j - st[i][j]]++;
        H[i][j + st[i][j] + 1]--;
      }
  for (int i = int(1); i < int(n + 1); i++)
    for (int j = int(1); j < int(m + 1); j++) {
      V[i][j] += V[i - 1][j];
      H[i][j] += H[i][j - 1];
      if (V[i][j] || H[i][j]) vst[i][j] = true;
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  memset(tb, false, sizeof(tb));
  for (int i = int(1); i < int(n + 1); i++)
    for (int j = int(1); j < int(m + 1); j++) {
      char c;
      cin >> c;
      if (c == '*') tb[i][j] = true;
    }
  for (int i = int(0); i < int(N); i++)
    for (int j = int(0); j < int(N); j++) st[i][j] = 10000;
  complete();
  solve();
  for (int i = int(1); i < int(n + 1); i++)
    for (int j = int(1); j < int(m + 1); j++) {
      if (tb[i][j] && !vst[i][j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  cout << (int)v.size() << endl;
  for (int i = int(0); i < int((int)v.size()); i++) {
    cout << v[i].first << " " << v[i].second << " "
         << st[v[i].first][v[i].second] << endl;
  }
  return 0;
}
