#include #define lowbit(x) x & (-x) #define pi pair #define ls(k) k << 1 #define rs(k) k << 1 | 1 #define fi first #define se second using namespace std; typedef __int128 __; typedef long double lb; typedef double db; typedef unsigned long long ull; typedef long long ll; const int N = 4e5 + 10; inline ll read(){ ll x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){ if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void write(ll x){ if(x < 0){ putchar('-'); x = -x; } if(x > 9) write(x / 10); putchar(x % 10 + '0'); } int n, m, q; string S; int h[N], c[N], a[N][3]; vector V[N]; queue Q[5]; int main() { n = read(), m = read(), q = read(); for(int i = 0; i < n; ++i){ cin >> S; for(int j = 0; j < m; ++j) h[j] += (S[j] == '#'); } for(int i = 0; i < q; ++i){ c[i] = read(); V[c[i]].push_back(i); } for(int x = 0; x < m; ++x){ for(int i = 2; i <= 4; ++i){ while(Q[i].size()){ Q[1].push(Q[i].front()); Q[i].pop(); } } for(auto v : V[x]) Q[0].push(v); for(int i = 0; i <= 3; ++i){ while(h[x] && Q[i].size()){ int y = Q[i].front(); Q[i].pop(); if(x >= c[y] + 3) continue; --h[x]; ++a[y][x - c[y]]; Q[i + 1 + (!i)].push(y); } } } for(int i = 0; i < q; ++i){ for(int j = 0; j < 3; ++j){ string ans = "..."; for(int x = 0; x < 3; ++x) if(a[i][x] > j) ans[x] = '#'; printf("%s\n", ans.c_str()); } } return 0; }