#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int r, c;
  cin >> r >> c;
  char arr1[r][c];
  char arr2[r][c];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> arr1[i][j];
      arr2[i][j] = arr1[i][j];
    }
  }
  int arrr1[r][c];
  int arrr2[r][c];
  int arrc1[r][c];
  int arrc2[r][c];
  for (int i = 0; i < r; i++) {
    int count = 0;
    for (int j = 0; j < c; j++) {
      if (arr1[i][j] == '.')
        count = 0;
      else
        count += 1;
      arrr1[i][j] = count;
    }
  }
  for (int i = 0; i < r; i++) {
    int count = 0;
    for (int j = c - 1; j >= 0; j--) {
      if (arr1[i][j] == '.')
        count = 0;
      else
        count += 1;
      arrr2[i][j] = count;
    }
  }
  for (int i = 0; i < c; i++) {
    int count = 0;
    for (int j = 0; j < r; j++) {
      if (arr1[j][i] == '.')
        count = 0;
      else
        count += 1;
      arrc1[j][i] = count;
    }
  }
  for (int i = 0; i < c; i++) {
    int count = 0;
    for (int j = r - 1; j >= 0; j--) {
      if (arr1[j][i] == '.')
        count = 0;
      else
        count += 1;
      arrc2[j][i] = count;
    }
  }
  int ansarr[r * c][3];
  int countx = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (i > 0 && i < r - 1 && j > 0 && j < c - 1) {
        if (arr1[i][j] == '*' && arr1[i - 1][j] == '*' &&
            arr1[i + 1][j] == '*' && arr1[i][j - 1] == '*' &&
            arr1[i][j + 1] == '*') {
          int count1 = arrr1[i][j];
          int count2 = arrr2[i][j];
          int count3 = arrc1[i][j];
          int count4 = arrc2[i][j];
          ansarr[countx][0] = i + 1;
          ansarr[countx][1] = j + 1;
          int x = 0;
          while (x != count1 && x != count2 && x != count3 && x != count4) {
            arr2[i - x][j] = '.';
            arr2[i + x][j] = '.';
            arr2[i][j - x] = '.';
            arr2[i][j + x] = '.';
            x += 1;
          }
          ansarr[countx][2] = x - 1;
          countx++;
        }
      }
    }
  }
  int flag = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (arr2[i][j] == '*') {
        cout << -1 << "\n";
        return 0;
      }
    }
  }
  if (flag == 1)
    cout << -1 << endl;
  else {
    cout << countx << endl;
    for (int i = 0; i < countx; i++) {
      cout << ansarr[i][0] << " " << ansarr[i][1] << " " << ansarr[i][2]
           << "\n";
    }
  }
  return 0;
}
