#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector A(h), B(w, string(h, '?')); vector> ans; 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); } } 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]; 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(p, x); } } sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); cout << ans.size() << '\n'; for(auto [y, x] : ans) cout << y + 1 << ' ' << x + 1 << '\n'; }