#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
using namespace std;
long long ESP = 1e18;
bool isPrime[1000000];
void sieve(long long int N) {
  for (long long i = 0; i <= N; ++i) {
    isPrime[i] = true;
  }
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i * i <= N; ++i) {
    if (isPrime[i] == true) {
      for (int j = i * i; j <= N; j += i) isPrime[j] = false;
    }
  }
}
bool anagram(char *s1, char *s2) {
  long long count[256];
  memset(count, 0, sizeof(count));
  long long i;
  for (i = 0; s1[i] && s2[i]; i++) {
    count[s1[i]]++;
    count[s2[i]]--;
  }
  if (s1[i] || s2[i]) {
    return false;
  }
  for (int(i) = 0; i < 256; ++i) {
    if (count[i]) {
      return false;
    }
  }
  return true;
}
int find_largest_digit(int n) {
  int mx = 0;
  while (n > 0) {
    mx = max(mx, n % 10);
    n /= 10;
  }
  return mx;
}
long long no_of_digits(long long n) {
  long long ans = 0;
  while (n > 0) {
    ans++;
    n /= 10;
  }
  return ans;
}
long long moduloMultiplication(long long a, long long b, long long zz) {
  long long res = 0;
  a %= zz;
  while (b) {
    if (b & 1) res = (res + a) % zz;
    a = (2 * a) % zz;
    b >>= 1;
  }
  return res;
}
long long to_int(string s) {
  bool o = true;
  long long ans = 0;
  for (long long i = 0; i < s.length(); i++) {
    ans = ans * 10 + (s[i] - 48);
  }
  return ans;
}
inline long long powmod(long long x, long long n, long long m) {
  if (n == 0 || x == 1)
    return 1;
  else if (n % 2 == 0) {
    return powmod((x * x) % m, n / 2, m);
  } else {
    return x * (powmod((x * x) % m, (n - 1) / 2, m)) % m;
  }
}
long long poww(long long a, long long b) {
  if (b == 0 || a == 1) return 1;
  long long half = poww(a, (b / 2));
  if (half < 0 || half > ESP) return -1;
  long long full = (half * half);
  if (half != 0 && full / half != half) {
    return -1;
  }
  if (b % 2) {
    if (full * a < 0 || full * a > ESP) return -1;
  }
  if (full < 0 || full > ESP) return -1;
  if (b % 2) {
    long long x = a * full;
    if (a != 0 && x / a != full) {
      return -1;
    }
    return (x);
  }
  return full;
}
long long invmod(long long a, long long modulo) {
  long long check = powmod(a, modulo - 2, modulo) % modulo;
  return check;
}
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  }
  return b;
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  }
  return b;
}
long long min(long long a, int b) {
  if (a < b) return a;
  return b;
}
long long min(int a, long long b) {
  if (a < b) return a;
  return b;
}
long long max(long long a, int b) {
  if (a > b) return a;
  return b;
}
long long max(int a, long long b) {
  if (a > b) return a;
  return b;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void yes() {
  cout << "YES"
       << "\n";
}
void no() {
  cout << "NO"
       << "\n";
}
vector<int> factorize(int n) {
  vector<int> res;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res.push_back(i);
      n /= i;
    }
  }
  if (n != 1) {
    res.push_back(n);
  }
  return res;
}
void printDivisors(int n) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        printf("%d ", i);
      else
        printf("%d %d ", i, n / i);
    }
  }
}
int phi(int n) {
  int result = n;
  for (int p = 2; p * p <= n; ++p) {
    if (n % p == 0) {
      while (n % p == 0) n /= p;
      result -= result / p;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
bool presents(vector<long long> v, int x) {
  bool flag = false;
  for (decltype(v.begin()) it = v.begin(); it != v.end(); it++) {
    if (*it == x) flag = true;
  }
  return flag;
}
long long ncr(long long n, long long r) {
  if (n < r) return 0;
  long long p = 1, k = 1;
  if (n - r < r) r = n - r;
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      long long m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else
    p = 1;
  return p;
}
int tc(char c) {
  int k = c - 97;
  return k;
}
void okms() {
  long long n, m;
  cin >> n >> m;
  string arr[n];
  for (int(i) = 0; i < n; ++i) cin >> arr[i];
  long long prex[n][m], prey[n][m], sufx[n][m], sufy[n][m];
  for (int(i) = 0; i < n; ++i) {
    for (int(j) = 0; j < m; ++j) {
      if (j == 0) {
        prex[i][j] = (arr[i][j] == '*') ? 1 : 0;
      } else {
        prex[i][j] = (arr[i][j] == '*') ? prex[i][j - 1] + 1 : 0;
      }
    }
  }
  for (int(i) = 0; i < n; ++i) {
    for (int(j) = m - 1; j >= 0; --j) {
      if (j == m - 1) {
        sufx[i][j] = (arr[i][j] == '*') ? 1 : 0;
      } else {
        sufx[i][j] = (arr[i][j] == '*') ? sufx[i][j + 1] + 1 : 0;
      }
    }
  }
  for (int(i) = 0; i < m; ++i) {
    for (int(j) = 0; j < n; ++j) {
      if (j == 0) {
        prey[j][i] = (arr[j][i] == '*') ? 1 : 0;
      } else {
        prey[j][i] = (arr[j][i] == '*') ? prey[j - 1][i] + 1 : 0;
      }
    }
  }
  for (int(i) = 0; i < m; ++i) {
    for (int(j) = n - 1; j >= 0; --j) {
      if (j == n - 1) {
        sufy[j][i] = (arr[j][i] == '*') ? 1 : 0;
      } else {
        sufy[j][i] = (arr[j][i] == '*') ? sufy[j + 1][i] + 1 : 0;
      }
    }
  }
  vector<pair<long long, pair<long long, long long> > > ans;
  for (int(i) = 0; i < n; ++i) {
    for (int(j) = 0; j < m; ++j) {
      if (arr[i][j] == '*') {
        long long k = min({sufx[i][j], prex[i][j], sufy[i][j], prey[i][j]});
        if (k == 1) continue;
        ans.push_back({k - 1, {i + 1, j + 1}});
      }
    }
  }
  string xx[n];
  for (int(i) = 0; i < n; ++i) {
    string pp;
    for (int(j) = 0; j < m; ++j) pp.push_back('.');
    xx[i] = pp;
  }
  for (auto v : ans) {
    long long y = v.second.first - 1;
    long long x = v.second.second - 1;
    long long k = v.first;
    for (int i = x - k; i <= x + k; i++) {
      xx[y][i] = '*';
    }
    for (int j = y - k; j <= y + k; j++) {
      xx[j][x] = '*';
    }
  }
  for (int(i) = 0; i < n; ++i) {
    for (int(j) = 0; j < m; ++j) {
      if (xx[i][j] != arr[i][j]) {
        cout << -1 << "\n";
        return;
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto v : ans)
    cout << v.second.first << " " << v.second.second << " " << v.first << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << showpoint;
  cout.precision(15);
  long long test;
  test = 1;
  while (test--) {
    okms();
  }
  return 0;
}
