/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BGridCompression {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, w;
	    in >> h >> w;
	    vector<vector<char>> a(h, vector<char>(w));
	    for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                in >> a[i][j];
            }
	    }

        map<int, int> hmp, wmp;
	    int hmpcnt = 0, wmpcnt = 0;
        for(int i=0; i<h; i++){
            bool flg = true;
            for(int j=0; j<w; j++){
                if(a[i][j] == '#'){
                    flg = false;
                    break;
                }
            }
            if(!flg){
                hmp[i] = 1;
                hmpcnt++;
            }
        }

        for(int i=0; i<w; i++){
            bool flg = true;
            for(int j=0; j<h; j++){
                if(a[j][i] == '#'){
                    flg = false;
                    break;
                }
            }
            if(!flg){
                wmp[i] = 1;
                wmpcnt++;
            }
        }

        vector<vector<char>> resg(h, vector<char>(w));
        int indh = 0, indw = 0;
        for(int i=0; i<h; i++){
            if(!hmp[i]) continue;
            for(int j=0; j<w; j++){
                if(!wmp[j]) continue;
                resg[indh][indw] = a[i][j];
                indw++;
            }
            indw = 0;
            indh++;
        }

        for(int i=0; i<hmpcnt; i++){
            for(int j=0; j<wmpcnt; j++){
                out << resg[i][j];
            }
            out << endl;
        }
	}
};


int main() {
	BGridCompression solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256