#include <bits/stdc++.h>
using namespace std;
int n, m;
bool vaild(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  char arr[n][m];
  int chec[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      chec[i][j] = 0;
    }
  }
  int cntU[n][m], cntD[n][m], cntL[n][m], cntR[n][m];
  for (int i = 0; i < m; i++) {
    int st = -1;
    for (int j = 0; j < n; j++) {
      if (arr[j][i] == '*' && st == -1) {
        st = j;
      } else if (arr[j][i] == '*') {
        cntU[j][i] = st;
      } else
        st = -1;
      cntU[j][i] = st;
    }
    st = -1;
    for (int j = n - 1; j >= 0; j--) {
      if (arr[j][i] == '*' && st == -1) {
        cntD[j][i] = j;
        st = j;
      } else if (arr[j][i] == '*') {
        cntD[j][i] = st;
      } else
        st = -1;
      cntD[j][i] = st;
    }
  }
  for (int i = 0; i < n; i++) {
    int st = -1;
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '*' && st == -1) {
        st = j;
      } else if (arr[i][j] == '*') {
        cntL[i][j] = st;
      } else
        st = -1;
      cntL[i][j] = st;
    }
    st = -1;
    for (int j = m - 1; j >= 0; j--) {
      if (arr[i][j] == '*' && st == -1) {
        cntR[i][j] = j;
        st = j;
      } else if (arr[i][j] == '*') {
        cntR[i][j] = st;
      } else
        st = -1;
      cntR[i][j] = st;
    }
  }
  vector<pair<int, pair<int, int>>> an;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '*') {
        int st = 1, en = max(n, m), ans = -1;
        while (st <= en) {
          int mid = (st + en) / 2;
          if (vaild(i + mid, j + mid) && vaild(i + mid, j - mid) &&
              vaild(i - mid, j + mid) && vaild(i - mid, j - mid)) {
            if (cntD[i - mid][j] != -1 && cntD[i - mid][j] >= i + mid &&
                cntR[i][j - mid] != -1 && cntR[i][j - mid] >= j + mid) {
              ans = mid;
              st = mid + 1;
            } else
              en = mid - 1;
          } else
            en = mid - 1;
        }
        if (ans != -1) {
          an.push_back({i + 1, {j + 1, ans}});
        }
      }
    }
  }
  for (int i = 0; i < an.size(); i++) {
    int x = an[i].first - 1;
    int y = an[i].second.first - 1;
    int len = an[i].second.second;
    for (int j = x; j <= x + len; j++) chec[j][y] = 1;
    for (int j = x; j >= x - len; j--) chec[j][y] = 1;
    for (int j = y; j <= y + len; j++) chec[x][j] = 1;
    for (int j = y; j >= y - len; j--) chec[x][j] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '*' && !chec[i][j]) return cout << -1, 0;
    }
  }
  cout << an.size() << endl;
  for (auto x : an)
    cout << x.first << " " << x.second.first << " " << x.second.second << '\n';
  return 0;
}
