#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000000 + 7;
long long quick_pow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
char a[1005][1005];
int n, m, s[1005][1005], ans;
bool vis[1005][1005];
bool panduan(int x, int y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == '*') return 1;
  return 0;
}
void dfs(int x, int y) {
  int k = 1;
  while (1) {
    if (panduan(x + k, y) && panduan(x - k, y) && panduan(x, y + k) &&
        panduan(x, y - k)) {
      vis[x + k][y] = true, vis[x - k][y] = true, vis[x][y + k] = true,
              vis[x][y - k] = true;
      k++;
    } else {
      k--;
      break;
    }
  }
  s[x][y] += k;
  if (k) ans++;
  if (k != 0) vis[x][y] = true;
}
int main() {
  ans = 0;
  scanf("%d%d", &n, &m);
  getchar();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%c", &a[i][j]);
    }
    getchar();
  }
  int aaa = quick_pow(10000000000, 100000000000000);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') dfs(i, j);
    }
  }
  int zzzz = quick_pow(22222222222, 222222222222);
  int o = 1;
  int ddddd = quick_pow(10000000000000, 10000000000);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!vis[i][j] && a[i][j] == '*') o = 0;
    }
  }
  int www = quick_pow(10000000000000, 3000003040000);
  if (!o) {
    printf("-1\n");
    return 0;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j]) {
        printf("%d %d %d\n", i, j, s[i][j]);
      }
    }
  }
}
