#include #include using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vs = vector; using vpi = vector>; using vpl = vector>; #define rep(i, s, n) for (int i = (s); i < (int)(n); ++i) #define repr(i, s, n) for (int i = (s); i >= (int)(n); --i) #define sz(x) ((int)(x).size()) template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} auto _ = []{ios::sync_with_stdio(false); cin.tie(nullptr); return 0;}(); const int INFI = 1 << 30; const ll INFL = 1LL << 62; vvi rotate (vvi& grid, int times) { int h = grid.size (); int w = grid[0].size (); vvi res=grid; times %= 4; rep (i, 0, times){ vvi rotatedGrid (w, vector (h)); rep (j, 0, h){ rep (k, 0, w) rotatedGrid[k][h - j - 1] = res[j][k]; } res = rotatedGrid; swap (h, w); } return res; } int main() { int h, w; cin >> h >> w; vvi a(h,vi(w,0)); vvi aa=a; rep (i, 0, h){ rep (j, 0, w){ char c; cin >> c; if(c=='#')a[i][j]=1; } } rep (j, 0, w){ int sm=0; rep (i, 0, h){ if(a[i][j])sm++; } rep (i, 0, sm){ aa[i][j]=1; } } vector>ans(h,vector(w,'.')); rep (i, 0, h){ int sm=accumulate(aa[i].begin(), aa[i].end(), 0); rep (j, 0, sm){ ans[i][j]='#'; } } for (auto x: ans){ for (auto y: x){ cout << y; } cout << '\n'; } return 0; }