#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) int h, w, n; int nb[10000]; int ans[30000][3]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w >> n; rep(i,h) { string s; cin >> s; rep(j,w) { if (s[j] == '#')nb[j]++; } } vector> pos; rep(i,n) { int c; cin >> c; pos.emplace_back(c, i); } sort(all(pos)); for (auto p : pos) { rep(x, 3) { if (nb[p.first + x]) { nb[p.first + x]--; ans[p.second][x]++; break; } } } for (auto p : pos) { rep(x, 3) { while (ans[p.second][x] < 3 && nb[p.first + x]) { nb[p.first + x]--; ans[p.second][x]++; } } } rep(i,n) { rep(y,3) { rep(x,3) { cout << (ans[i][x] > y ? '#' : '.'); } cout << endl; } } return 0; }