#include <bits/stdc++.h>
using namespace std;
string sizes[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int n, cnt[7];
map<string, int> leftNode, rightNode, myMap;
int source, dest;
int id = 0;
const int nmax = 300;
vector<int> gf[nmax];
vector<string> v[100005];
int capac[nmax][nmax];
const int inf = (1 << 30);
int t[nmax], q[2000], flux[nmax][nmax];
bool viz[nmax];
int N;
string ans[100005];
string concat(string s1, string s2) { return s1 + s2; }
int getNode(string s) { return leftNode[s]; }
int getNode(string s1, string s2) { return leftNode[concat(s1, s2)]; }
int getNodeRight(string s) { return rightNode[s]; }
void addEdge(int x, int y, int c) {
  gf[x].push_back(y);
  gf[y].push_back(x);
  capac[x][y] = c;
}
int getNext() {
  ++id;
  return id;
}
bool bfs(int S, int D) {
  for (int i = S; i <= D; ++i) viz[i] = 0;
  int st = 1;
  int dr = 0;
  q[++dr] = S;
  viz[S] = 1;
  for (; st <= dr;) {
    int nod = q[st];
    ++st;
    for (int i = 0; i < gf[nod].size(); ++i) {
      int vc = gf[nod][i];
      if (viz[vc] == 0 && capac[nod][vc] > flux[nod][vc]) {
        t[vc] = nod;
        viz[vc] = 1;
        if (vc == D) return 1;
        q[++dr] = vc;
      }
    }
  }
  return 0;
}
void rezolva() {
  int Flux = 0;
  for (; bfs(source, dest);) {
    int Min = inf;
    for (int i = dest; i != source; i = t[i]) {
      Min = min(Min, capac[t[i]][i] - flux[t[i]][i]);
    }
    for (int i = dest; i != source; i = t[i]) {
      flux[t[i]][i] += Min;
      flux[i][t[i]] -= Min;
    }
    Flux += Min;
  }
  if (Flux < N) {
    cout << "NO\n";
    return;
  }
  for (int i = 1; i <= n; ++i) {
    if (v[i].size() > 1) {
      int node = getNode(v[i][0], v[i][1]);
      int node1 = getNodeRight(v[i][0]);
      int node2 = getNodeRight(v[i][1]);
      if (flux[node][node1] > 0) {
        --flux[node][node1];
        ans[i] = v[i][0];
      } else {
        --flux[node][node2];
        ans[i] = v[i][1];
      }
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  for (int i = 1; i <= 6; ++i) {
    cin >> cnt[i];
  }
  cin >> n;
  cin.get();
  source = 0;
  for (int i = 0; i < 5; ++i) {
    leftNode[concat(sizes[i], sizes[i + 1])] = getNext();
  }
  for (int i = 0; i < 6; ++i) {
    myMap[sizes[i]] = i + 1;
  }
  for (int i = 0; i < 6; ++i) {
    rightNode[sizes[i]] = getNext();
  }
  dest = getNext();
  N = n;
  for (int i = 1; i <= n; ++i) {
    string s;
    getline(cin, s);
    string s1, s2;
    int ok = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == ',') {
        ok = 1;
        continue;
      }
      if (ok) {
        s2 += s[j];
      } else {
        s1 += s[j];
      }
    }
    v[i].push_back(s1);
    if (s2.size() > 0) {
      v[i].push_back(s2);
    }
    if (v[i].size() == 1) {
      if (cnt[myMap[v[i][0]]] == 0) {
        cout << "NO\n";
        return 0;
      }
      cnt[myMap[v[i][0]]]--;
      ans[i] = v[i][0];
      --N;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (v[i].size() == 1) {
      continue;
    }
    string s1 = v[i][0];
    string s2 = v[i][1];
    int node = getNode(s1, s2);
    addEdge(source, node, capac[source][node] + 1);
  }
  for (int i = 0; i < 6; ++i) {
    addEdge(getNodeRight(sizes[i]), dest, cnt[i + 1]);
  }
  for (int i = 0; i < 5; ++i) {
    addEdge(getNode(sizes[i], sizes[i + 1]), getNodeRight(sizes[i]), inf);
    addEdge(getNode(sizes[i], sizes[i + 1]), getNodeRight(sizes[i + 1]), inf);
  }
  rezolva();
  return 0;
}
