#include using namespace std; typedef long long ll; #define int ll const int N=5e5+7; int n,m,k,cnt[N],a[N],res[N][3]; vectorT[N]; signed main(){ // freopen("tetris.in","r",stdin); // freopen("tetris.out","w",stdout); cin>>n>>m>>k; for (int i=1;i<=n;i++) for (int j=1;j<=m;j++){ char ch;cin>>ch; if(ch=='#')cnt[j]++; } for(int i=1;i<=k;i++)cin>>a[i],a[i]++,T[a[i]].push_back(i); for(int i=1;i<=m;i++) for (int x:T[i]){ if(cnt[i])res[x][0]++,cnt[i]--; else if(i+1<=m&&cnt[i+1])res[x][1]++,cnt[i+1]--; else if(i+2<=m&&cnt[i+2])res[x][2]++,cnt[i+2]--; } for(int i=1;i<=m;i++) for (int x:T[i]) for(int k=0;k<3;k++) if(i+k<=m){ int p=res[x][k]; res[x][k]+=cnt[i+k]; cnt[i+k]-=min(3-p,cnt[i+k]); } for (int i=1;i<=k;i++) for (int j=1;j<=3;j++){ for (int k=0;k<3;k++) if(j<=res[i][k]) cout<<'#'; else cout<<'.'; cout<<"\n"; } }