#include using namespace std; using ull = uint64_t; using ll = int64_t; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define N4(f) \ f(0,1) \ f(0,-1) \ f(1,0) \ f(-1,0) #define N8(f) \ f(y+1,x+1) \ f(y+1,x+0) \ f(y+1,x-1) \ f(y+0,x+1) \ f(y+0,x-1) \ f(y-1,x+1) \ f(y-1,x+0) \ f(y-1,x-1) #define N9(f) \ f(y+1,x+1) \ f(y+1,x+0) \ f(y+1,x-1) \ f(y+0,x+1) \ f(y+0,x+0) \ f(y+0,x-1) \ f(y-1,x+1) \ f(y-1,x+0) \ f(y-1,x-1) signed main() { int n,m;cin>>n>>m; vector v(m); rep(i,n) { string s;cin>>s; rep(j,m) { if(s[j]=='#') { v[j]++; } } } sort(v.begin(),v.end(),greater{}); vectorvv(n); rep(i,m) { rep(j,v[i]) { vv[j]++; } } rep(i,n) { rep(j,vv[i])cout<<'#'; rep(j,m-vv[i])cout<<'.'; cout<<'\n'; } cout<