func_code_string: #include <bits/stdc++.h>   using namespace std;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a << endl;     err(++it, args...);   }   long long mod = 1e9 + 7;   long long powm(long long a, long long b, long long mod) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first);   }   void solve() {     int n, m;     cin >> n >> m;     string s[n];     for (long long i = 0; i < (n); i++) cin >> s[i];     int mat1[n][m];     int mat2[n][m];     int mat3[n][m];     int mat4[n][m];     memset(mat1, 0, sizeof(mat1));     memset(mat2, 0, sizeof(mat2));     memset(mat3, 0, sizeof(mat3));     memset(mat4, 0, sizeof(mat4));     for (long long i = 0; i < (n); i++) {       for (long long j = 0; j < (m); j++) {         if (s[i][j] ==  * ) {           if (j - 1 >= 0)             mat1[i][j] += 1 + mat1[i][j - 1];           else             mat1[i][j] = 1;         }       }     }     for (long long i = 0; i < (n); i++) {       for (long long j = (m)-1; j >= 0; j--) {         if (s[i][j] ==  * ) {           if (j + 1 < m)             mat2[i][j] += 1 + mat2[i][j + 1];           else             mat2[i][j] = 1;         }       }     }     for (long long j = 0; j < (m); j++) {       for (long long i = 0; i < (n); i++) {         if (s[i][j] ==  * ) {           if (i - 1 >= 0)             mat3[i][j] += 1 + mat3[i - 1][j];           else             mat3[i][j] = 1;         }       }     }     for (long long j = 0; j < (m); j++) {       for (long long i = (n)-1; i >= 0; i--) {         if (s[i][j] ==  * ) {           if (i + 1 < n)             mat4[i][j] += 1 + mat4[i + 1][j];           else             mat4[i][j] = 1;         }       }     }     int temp_mat2[n + 1][m + 1];     int temp_mat1[n + 1][m + 1];     memset(temp_mat1, 0, sizeof(temp_mat1));     memset(temp_mat2, 0, sizeof(temp_mat2));     vector<tuple<int, int, int> > v;     for (long long i = 0; i < (n); i++) {       for (long long j = 0; j < (m); j++) {         if (mat1[i][j] > 1 and mat2[i][j] > 1 and mat3[i][j] > 1 and             mat4[i][j] > 1) {           temp_mat1[i][j - min({mat1[i][j], mat2[i][j], mat3[i][j], mat4[i][j]}) +                        1]++;           temp_mat1[i]                    [j + min({mat1[i][j], mat2[i][j], mat3[i][j], mat4[i][j]})]--;           temp_mat2[i - min({mat1[i][j], mat2[i][j], mat3[i][j], mat4[i][j]}) + 1]                    [j]++;           temp_mat2[i + min({mat1[i][j], mat2[i][j], mat3[i][j], mat4[i][j]})]                    [j]--;           v.push_back(make_tuple(               i + 1, j + 1,               min({mat1[i][j], mat2[i][j], mat3[i][j], mat4[i][j]}) - 1));         }       }     }     for (long long i = 0; i < (n); i++) {       for (long long j = 0; j < (m); j++) {         if (j > 0) temp_mat1[i][j] += temp_mat1[i][j - 1];       }     }     for (long long j = 0; j < (m); j++) {       for (long long i = 0; i < (n); i++) {         if (i > 0) temp_mat2[i][j] += temp_mat2[i - 1][j];       }     }     for (long long i = 0; i < (n); i++) {       for (long long j = 0; j < (m); j++) {         if (s[i][j] ==  * ) {           if (temp_mat1[i][j] == 0 and temp_mat2[i][j] == 0) {             cout << -1 << endl;             return;           }         }       }     }     cout << v.size() << endl;     for (long long i = 0; i < (v.size()); i++) {       cout << (get<0>(v[i])) <<     << (get<1>(v[i])) <<     << (get<2>(v[i]))            << endl;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }   