#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector A(h), B(w, string(h, '?')); vector> ans; vector> C(h, vector(w, 0)); for(int y = 0; y < h; y++){ auto &&ss = A[y]; cin >> ss; for(int i = 0; i < w; ){ int p = i; while(i < w && ss[i] == ss[p]) i++; if(ss[p] == '#') continue; if(i - p >= 2) ans.emplace_back(y, p), C[y][p] |= 1; } } for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ B[x][y] = A[y][x]; } } for(int x = 0; x < w; x++){ auto &&ss = B[x]; for(int i = 0; i < h; ){ int p = i; while(i < h && ss[i] == ss[p]) i++; if(ss[p] == '#') continue; if(i - p >= 2) ans.emplace_back(p, x), C[p][x] |= 2; } } sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); for(auto &&s : A){ for(int x = 0; x < w; x++){ if(s[x] == '.') s[x] = 'a'; } } auto ext_x = [&](int y, int x) -> string { if(~C[y][x] & 1) return "-"; string res; while(x < w && A[y][x] != '#') res += A[y][x++]; return res; }; auto ext_y = [&](int y, int x) -> string { if(~C[y][x] & 2) return "-"; string res; while(y < h && A[y][x] != '#') res += A[y++][x]; return res; }; cout << ans.size() << '\n'; for(auto [y, x] : ans){ cout << ext_x(y, x) << ' ' << ext_y(y, x) << '\n'; } }