#include <stdio.h>
#include <stdlib.h>
#include <string.h>



void life_step(char **grid, int rows, int cols) {
    // TODO: for each cell count its live neighbours from the CURRENT board,
    //       compute the next generation into a separate buffer, then copy the
    //       buffer back into grid. Remember cells off the board are dead.
    (void)grid; (void)rows; (void)cols;
}


int main(void) {
    int rows, cols, steps;
    if (scanf("%d %d %d", &rows, &cols, &steps) != 3) return 0;
    char **grid = malloc(sizeof(char *) * rows);
    char buf[1024];
    for (int r = 0; r < rows; r++) {
        if (scanf("%1023s", buf) != 1) return 0;
        grid[r] = malloc(cols + 1);
        for (int c = 0; c < cols; c++) grid[r][c] = (c < (int)strlen(buf) && buf[c] == '*') ? '*' : '.';
        grid[r][cols] = '\0';
    }
    for (int s = 0; s < steps; s++) life_step(grid, rows, cols);
    for (int r = 0; r < rows; r++) printf("%s\n", grid[r]);
    for (int r = 0; r < rows; r++) free(grid[r]);
    free(grid);
    return 0;
}
