#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c;
  cin >> r;
  cin >> c;
  char arr[r][c];
  for (int i = 0; i < r; i++) {
    string str;
    cin >> str;
    for (int j = 0; j < c; j++) {
      arr[i][j] = str[j];
    }
  }
  vector<tuple<int, int, int>> ans;
  char made[r][c];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      made[i][j] = '.';
    }
  }
  int up[r][c];
  int down[r][c];
  int left[r][c];
  int right[r][c];
  for (int j = 0; j < c; j++) {
    if (arr[0][j] == '*') {
      up[0][j] = 0;
    }
    for (int i = 1; i < r; i++) {
      if (arr[i][j] == '*') {
        if (arr[i - 1][j] == '*') {
          up[i][j] = up[i - 1][j];
        } else {
          up[i][j] = i;
        }
      }
    }
  }
  for (int j = 0; j < c; j++) {
    if (arr[r - 1][j] == '*') {
      down[r - 1][j] = r - 1;
    }
    for (int i = r - 2; i >= 0; i--) {
      if (arr[i][j] == '*') {
        if (arr[i + 1][j] == '*') {
          down[i][j] = down[i + 1][j];
        } else {
          down[i][j] = i;
        }
      }
    }
  }
  for (int i = 0; i < r; i++) {
    if (arr[i][0] == '*') {
      left[i][0] = 0;
    }
    for (int j = 1; j < c; j++) {
      if (arr[i][j] == '*') {
        if (arr[i][j - 1] == '*') {
          left[i][j] = left[i][j - 1];
        } else {
          left[i][j] = j;
        }
      }
    }
  }
  for (int i = 0; i < r; i++) {
    if (arr[i][c - 1] == '*') {
      right[i][c - 1] = c - 1;
    }
    for (int j = c - 2; j >= 0; j--) {
      if (arr[i][j] == '*') {
        if (arr[i][j + 1] == '*') {
          right[i][j] = right[i][j + 1];
        } else {
          right[i][j] = j;
        }
      }
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (arr[i][j] == '*') {
        int v, h;
        int len = i - up[i][j];
        len = min(len, down[i][j] - i);
        len = min(len, j - left[i][j]);
        len = min(len, right[i][j] - j);
        if (len > 0) {
          made[i][j] = '*';
          v = i;
          for (int cnt = 0; cnt < len; cnt++) {
            v--;
            made[v][j] = '*';
          }
          v = i;
          for (int cnt = 0; cnt < len; cnt++) {
            v++;
            made[v][j] = '*';
          }
          h = j;
          for (int cnt = 0; cnt < len; cnt++) {
            h--;
            made[i][h] = '*';
          }
          h = j;
          for (int cnt = 0; cnt < len; cnt++) {
            h++;
            made[i][h] = '*';
          }
          ans.push_back(make_tuple(i, j, len));
        }
      }
    }
  }
  bool flag = true;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (arr[i][j] == '*' && made[i][j] != '*') {
        flag = false;
        break;
      }
    }
  }
  if (flag) {
    cout << ans.size() << "\n";
    for (auto it : ans) {
      int x = get<0>(it);
      int y = get<1>(it);
      int z = get<2>(it);
      x++;
      y++;
      cout << x << " " << y << " " << z << "\n";
    }
  } else {
    cout << -1 << "\n";
  }
  return 0;
}
