#include <bits/stdc++.h>

using namespace std;

#define     mp              make_pair
#define     fs              first
#define     sc              second
#define     pob             pop_back
#define     pub             push_back
#define     eps             1E-7
#define     sz(a)           a.size()
#define     count_one       __builtin_popcount;
#define     count_onell     __builtin_popcountll;
#define     fastIO          ios_base::sync_with_stdio(false)
#define     PI              (acos(-1.0))
#define     linf            (1LL<<62)//>4e18
#define     inf             (0x7f7f7f7f)//>2e9

#define MAXN 1010

int n, m, h;
int out[MAXN][MAXN];
int xori[MAXN], xora[MAXN];

int main() {
#ifndef ONLINE_JUDGE
freopen("D:/C++/in", "r", stdin);
freopen("D:/C++/out", "w", stdout);
#endif

    cin >> n >> m >> h;
    char c;
    cin.get(c);

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            cin.get(c);
            if(c == '#')
                out[i][j] = 1;
            else
                out[i][j] = 0;
        }
        cin.get(c);
    }

    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= m; ++j) {
            cin.get(c);
            if(c == '#')
                xori[j]++;
        }
        cin.get(c);
    }

    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= n; ++j) {
            cin.get(c);
            if(c == '#')
                xora[j]++;
        }
        cin.get(c);
    }

    for(int i = n; i > 0; --i) {
        for(int j = 1; j <= m; ++j) {
            out[i][j] *= xori[j];
        }
    }

    int found, curr;

    for(int i = n; i > 0; --i) {
        found = 0;
        for(int j = m; j > 0; --j) {
            if(out[i][j]) {
                out[i][j] = min(xori[j], xora[n - i + 1]);
            }
        }
    }

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j)
            if(out[i][j] == 0)
                cout << '.';
            else
                cout << out[i][j];
        cout << "\n";
    }
    return 0;
}