// Arup Guha
// 6/19/2025
// Solution to Falling Snow (2)
// https://open.kattis.com/problems/fallingsnow2

using namespace std;
#include <bits/stdc++.h>

int main() {

    int r, c;
    cin >> r >> c;

    // Store how many snowflakes in each column.
    vector<int> freq(c, 0);

    // Read in choices.
    for (int i=0; i<r; i++) {
        string s;
        cin >> s;

        // Add 1 to each column with a snowflake.
        for (int j=0; j<c; j++)
            if (s[j] == 'S')
                freq[j]++;
    }

    // Go through rows backwards...
    for (int i=r; i>0; i--) {

        // For each column just test if there's enough snow or not to print here.
        for (int j=0; j<c; j++) {
            if (freq[j] >= i)
                cout << "S";
            else
                cout << ".";
        }

        // Next line...
        cout << endl;
    }

    return 0;
}
