#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long double PI = acos((long double)-1);
void solve() {
  int n, m;
  cin >> n >> m;
  string grid[n];
  for (int i = 0; i < n; ++i) {
    cin >> grid[i];
  }
  int up[n][m], down[n][m], left[n][m], right[n][m];
  memset(up, 0, sizeof(up));
  memset(down, 0, sizeof(down));
  memset(left, 0, sizeof(left));
  memset(right, 0, sizeof(right));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') {
        up[i][j] = 0;
      } else {
        up[i][j] = 1;
        if (i - 1 >= 0) {
          up[i][j] += up[i - 1][j];
        }
      }
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') {
        down[i][j] = 0;
      } else {
        down[i][j] = 1;
        if (i + 1 < n) {
          down[i][j] += down[i + 1][j];
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') {
        left[i][j] = 0;
      } else {
        left[i][j] = 1;
        if (j - 1 >= 0) {
          left[i][j] += left[i][j - 1];
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = m - 1; j >= 0; --j) {
      if (grid[i][j] == '.') {
        right[i][j] = 0;
      } else {
        right[i][j] = 1;
        if (j + 1 < m) {
          right[i][j] += right[i][j + 1];
        }
      }
    }
  }
  bool visited[n][m];
  memset(visited, 0, sizeof(visited));
  vector<vector<int>> res;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') continue;
      int mini =
          min({up[i][j] - 1, left[i][j] - 1, right[i][j] - 1, down[i][j] - 1});
      if (mini <= 0) continue;
      vector<int> temp = {i + 1, j + 1, mini};
      for (int r = i; r <= i + mini; ++r) {
        visited[r][j] = true;
      }
      for (int r = i; r >= i - mini; --r) {
        visited[r][j] = true;
      }
      for (int c = j; c >= j - mini; --c) {
        visited[i][c] = true;
      }
      for (int c = j; c <= j + mini; ++c) {
        visited[i][c] = true;
      }
      res.push_back(temp);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.') continue;
      if (visited[i][j])
        continue;
      else {
        cout << -1 << '\n';
        return;
      }
    }
  }
  cout << res.size() << '\n';
  for (vector<int> vect : res) {
    for (int x : vect) {
      cout << x << " ";
    }
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
