#include #include #include #include #define REP(i, a, b) for (int i = int(a); i < int(b); i++) #ifdef _DEBUG_ #define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl #else #define dump(val) #endif using namespace std; typedef long long int ll; template vector make_v(size_t a, T b) { return vector(a, b); } template auto make_v(size_t a, Ts... ts) { return vector(a, make_v(ts...)); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int w, h, n; cin >> h >> w >> n; vector M(w, 0); REP(i, 0, h) { string s; cin >> s; REP(j, 0, s.size()) { M[j] += (s[j] == '#'); } } vector C(n); vector X(w, 0); REP(i, 0, n) { cin >> C[i]; X[C[i]]++; } vector I(n); REP(i, 0, n) { I[i] = i; } sort(begin(I), end(I), [&](int a, int b) { return C[a] < C[b]; }); int l = 0, r = 0, index = 0; auto ans = make_v(n, 4, 0); REP(i, 0, w) { r += X[i]; index = max(index, l); REP (j, l, r) { if (ans[I[j]][3] == 0) { index = j; break; } } REP(j, 0, M[i]) { ans[I[index]][i - C[I[index]]]++; ans[I[index]][3]++; index = l + ((index + 1 - l) % (r - l)); } if (i - 2 >= 0) { l += X[i - 2]; } } REP (i, 0, n) { REP (j, 0, 3) { REP (k, 0, 3) { cout << (ans[i][k] > j ? '#' : '.'); } cout << endl; } } return 0; }