#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF (1<<29) #define LINF (1LL<<60) #define EPS (1e-10) #define PI 3.1415926535897932384626433832795028 typedef long long Int; typedef pair P; typedef long double Real; typedef complex CP; bool edge[4400][4400]; Int h, w; Int a[4400], b[4400]; string ans[2200]; void ok(){ cout << "Yes" << endl; exit(0); } void ng(){ cout << ":(" << endl; exit(0); } bool come[4400]; bool f(int s){ if(come[s])return false; come[s] = true; if(s >= h && b[s-h]){ b[s-h]--; return true; } for(int i = 0;i < 4400;i++){ if(edge[s][i] && f(i)){ edge[s][i] = false; edge[i][s] = true; return true; } } return false; } int main(){ cin >> h >> w; for(int i = 0;i < h;i++)ans[i] = string(w, '.'); for(int i = 0;i < h;i++)cin >> a[i]; for(int i = 0;i < w;i++)cin >> b[i]; for(int i = 0;i < h;i++){ for(int j = 0;j < w;j++){ edge[i][j+h] = true; } } for(int i = 0;i < h;i++){ vector

bs; for(int j = 0;j < w;j++)bs.push_back({b[j], j}); sort(bs.rbegin(), bs.rend()); for(int j = 0;j < w;j++){ if(a[i]>0 && bs[j].first>0){ // cout << i << " " << bs[j].second << endl; a[i]--; b[bs[j].second]--; edge[i][bs[j].second+h] = false; edge[bs[j].second+h][i] = true; } } } for(int i = 0;i < h;i++)if(a[i])ng(); for(int i = 0;i < w;i++)if(b[i])ng(); int k; cin >> k; for(int i = 0;i < k;i++){ int x, y; cin >> x >> y;x--,y--; ans[x][y] = 'x'; if(edge[y+h][x]){ edge[y+h][x] = false; a[x]++; b[y]++; } else{ edge[x][y+h] = false; } } for(int i = 0;i < h;i++){ while(a[i]){ fill(come, come + 4400, false); if(f(i))a[i]--; else ng(); } } cout << "Yay!" << endl; for(int i = 0;i < h;i++){ int cnt = 0; for(int j = 0;j < w;j++){ if(edge[j+h][i]){ ans[i][j] = 'o'; cnt++; } } cout << ans[i] << endl; } return 0; }