#include using namespace std; typedef long long ll; typedef long double ld; typedef pair ii; typedef vector vi; typedef vector vvi; typedef vector vii; #define x first #define y second #define pb push_back #define eb emplace_back #define rep(i,a,b) for(auto i=(a); i<(b); ++i) #define REP(i,n) rep(i,0,n) #define all(v) (v).begin(), (v).end() #define rs resize #define DBG(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl const ld PI = acos(-1.0); template using min_queue = priority_queue, greater>; template int sz(const T &x) { return (int) x.size(); // copy the ampersand(&)! } template ostream& operator<<(ostream &os, vector &v) { os << "\n["; for(T &x : v) os << x << ','; return os << "]\n"; } struct pairhash { public: template size_t operator()(const pair &p) const { size_t lhs = hash()(p.x); size_t rhs = hash()(p.y); return lhs ^ (rhs+0x9e3779b9+(lhs<<6)+(lhs>>2)); } }; vector> rotate(vector> A) { ll w = A.size(); ll h = A[0].size(); vector> B(h, vector(w)); for (ll i = 0; i < w; i++) { for (ll j = 0; j < h; j++) { B[j][w-i-1] = A[i][j]; } } return B; } bool check(vector> A) { ll h = A.size(); ll w = A[0].size(); for (ll i = 1; i < h; i++) { for (ll j = 0; j < w; j++) { if (A[i][j] && !A[i-1][j]) return false; } } return true; } void print(vector> A) { ll h = A.size(); ll w = A[0].size(); cout << h << " " << w << endl; for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) { cout << (A[i][j] ? "." : "#"); } cout << endl; } } void run() { ll h, w; cin >> h >> w; vector> A(h, vector(w)); for (ll i = 0; i < h; i++) { string s; cin >> s; for (ll j = 0; j < w; j++) { A[i][j] = (s[j] == '#'); } } for (ll k = 0; k < 4; k++) { if (check(A)) { print(A); return; } A = rotate(A); } cout << "impossible" << endl; } signed main() { // DON'T MIX "scanf" and "cin"! ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(20); run(); return 0; }