#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, y, s, ans;
char a[2222][2222];
int l[2222][2222], r[2222][2222], u[2222][2222], d[2222][2222];
pair<pair<int, int>, int> st[2444444];
bool f[2222][2222];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (a[i][j] == '*')
        l[i][j] = l[i][j - 1] + 1;
      else
        l[i][j] = 0;
  for (i = 1; i <= n; i++)
    for (j = m; j >= 1; j--)
      if (a[i][j] == '*')
        r[i][j] = r[i][j + 1] + 1;
      else
        r[i][j] = 0;
  for (j = 1; j <= m; j++)
    for (i = 1; i <= n; i++)
      if (a[i][j] == '*')
        u[i][j] = u[i - 1][j] + 1;
      else
        u[i][j] = 0;
  for (j = m; j >= 1; j--)
    for (i = n; i >= 1; i--)
      if (a[i][j] == '*')
        d[i][j] = d[i + 1][j] + 1;
      else
        d[i][j] = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (a[i][j] == '*') {
        s = min(min(r[i][j + 1], l[i][j - 1]), min(u[i - 1][j], d[i + 1][j]));
        if (s > 0) {
          st[++ans] = {{i, j}, s};
          for (y = j - s; y <= j + s; y++) f[i][y] = 1;
          for (y = i - s; y <= i + s; y++) f[y][j] = 1;
        }
      }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (a[i][j] == '*' && f[i][j] == 0) {
        cout << -1 << "\n";
        return 0;
      }
  cout << ans << "\n";
  for (i = 1; i <= ans; i++)
    cout << st[i].first.first << " " << st[i].first.second << " "
         << st[i].second << "\n";
  return 0;
}
