#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
namespace Dup4 {
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) f ^= (c == '-');
  for (; isdigit(c); c = getchar()) x = x * 10 + (c - '0');
  return x * (f ? 1 : -1);
}
template <typename T>
inline void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) f ^= (c == '-');
  for (; isdigit(c); c = getchar()) x = x * 10 + (c - '0');
  x *= f ? 1 : -1;
}
template <typename T>
inline void out(T x) {
  if (!x) {
    putchar(48);
    return;
  }
  if (x < 0) x = -x, putchar('-');
  int bit[20], i, p = 0;
  for (; x; x /= 10) bit[++p] = x % 10;
  for (i = p; i; --i) putchar(bit[i] + 48);
}
template <typename T>
inline void output(T x) {
  out(x), putchar('\n');
}
template <typename T>
inline T gcd(T a, T b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
const double PI = acos(-1.0);
const double EI = exp(1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fll;
}  // namespace Dup4
using namespace Dup4;
namespace FastIO {
bool IOerror = false;
inline char NC() {
  static char buf[10000005], *p1 = buf + 10000005, *pend = buf + 10000005;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 10000005, stdin);
    if (pend == p1) {
      IOerror = true;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void __read(char &x) {
  char ch;
  while (blank(ch = NC()))
    ;
  if (IOerror) {
    x = -1;
    return;
  }
  x = ch;
}
template <typename T>
inline void __read(T &x) {
  char ch;
  while (blank(ch = NC()))
    ;
  if (IOerror) {
    x = -1;
    return;
  }
  bool flag = false;
  if (ch == '-') {
    flag = true;
    ch = NC();
  }
  if (!isdigit(ch))
    while (!isdigit(ch = NC()))
      ;
  for (x = ch - '0'; isdigit(ch = NC()); x = x * 10 + ch - '0')
    ;
  if (flag) x *= -1;
}
}  // namespace FastIO
using namespace FastIO;
const int maxn = (int)1e3 + 10;
const int Maxn = (int)2e6 + 10;
const int MOD = (int)1e9 + 7;
int n, m;
int G[maxn][maxn];
int ans[maxn][maxn];
int row[maxn][maxn], line[maxn][maxn];
inline bool Input() {
  if (__read(n), __read(m), n == EOF) return false;
  char c;
  memset(ans, (0), sizeof(ans));
  ;
  memset(row, (0), sizeof(row));
  ;
  memset(line, (0), sizeof(line));
  ;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      __read(c);
      G[i][j] = (c == '*' ? 1 : 0);
      row[i][j] += G[i][j] + row[i][j - 1];
      line[j][i] += G[i][j] + line[j][i - 1];
    }
  return true;
}
struct node {
  int x, y, s;
  inline node() {}
  inline node(int x, int y, int s) : x(x), y(y), s(s) {}
};
inline bool ok(int x, int y, int s) {
  if (x - s < 1 || y - s < 1) return false;
  if (x + s > n || y + s > m) return false;
  int l = y - s, r = y + s;
  int up = x - s, down = x + s;
  if (row[x][r] - row[x][l - 1] != (r - l + 1)) return false;
  if (line[y][down] - line[y][up - 1] != (down - up + 1)) return false;
  return true;
}
inline void work(int x, int y, int s) {
  for (int i = (x - s); i <= (x + s); ++i) ans[i][y] = 1;
  for (int i = (y - s); i <= (y + s); ++i) ans[x][i] = 1;
}
inline bool judge() {
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j)
      if (G[i][j] != ans[i][j]) return false;
  return true;
}
inline void Solve() {
  vector<node> ans;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j)
      if (G[i][j]) {
        int l = 1, r = max(n << 1, m << 1), tar = 0;
        while (r - l >= 0) {
          int mid = (l + r) >> 1;
          if (ok(i, j, mid)) {
            tar = mid;
            l = mid + 1;
          } else
            r = mid - 1;
        }
        if (tar) {
          work(i, j, tar);
          ans.emplace_back(i, j, tar);
        }
      }
  if (judge() == false) {
    puts("-1");
    return;
  }
  printf("%d\n", ans.size());
  for (auto it : ans) printf("%d %d %d\n", it.x, it.y, it.s);
}
int main() {
  while (Input()) Solve();
  return 0;
}
