import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.StringTokenizer;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.ToIntBiFunction;

public class Mark {

    public static void main(String[] args) throws IOException {
        FastReader fr = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);

        int R = fr.nextInt(), C = fr.nextInt();
        char[][] map = new char[R][];
        for (int i = 0; i < R; ++i)
            map[i] = fr.next().toCharArray();
        for (int i = 0; i < C; ++i)
            for (int j = 0; j < R; ++j)
                if (map[j][i] != '.')
                    pw.print(map[j][i]);
        pw.println();

        pw.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            st = null;
            return str;
        }
    }

}