#include <iostream>
#include <cstdio>
#include <queue>
#include <functional>
#define DMAX 1020
using namespace std;

int mat[DMAX][DMAX], X[DMAX][DMAX], Y[DMAX][DMAX];
int x[DMAX], y[DMAX];
int n, m, h;
char c;

void print_mat()
{
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
            if(mat[i][j]==-1)
                cout<<'.';
            else
                cout<<mat[i][j];

        cout<<'\n';
    }

}

int main()
{
    freopen("in.txt", "r", stdin);
    cin>>n>>m>>h;

    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
        {
            cin>>c;
            if(c=='.') mat[i][j]=-1;
            else mat[i][j]=-2;
        }

    for(int i=1; i<=h; i++)
        for(int j=1; j<=m; j++)
        {
            cin>>c;
            if(c=='.') X[i][j]=0;
            else X[i][j]=1;
        }

    for(int i=1; i<=h; i++)
        for(int j=1; j<=n; j++)
        {
            cin>>c;
            if(c=='.') Y[i][j]=0;
            else Y[i][j]=1;
        }

    for(int i=1; i<=m; i++)
        for(int j=1; j<=h; j++)
            x[i]+=X[j][i];

    for(int i=1; i<=n; i++)
        for(int j=1; j<=h; j++)
            y[i]+=Y[j][n-i+1];

    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
        {
            if(mat[i][j]==-2)
                mat[i][j]=min(x[j], y[i]);
        }
    print_mat();
    return 0;
}