#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
const long long inf = 2147383647;
const long long mod = 1000000007;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct node {
  int x, y, next, cap, cost;
};
struct FLOW {
  int source, sink;
  int head[100030];
  void clear() {
    e = 0;
    memset(head, -1, sizeof(head));
  }
  node edge[800030];
  int e;
  void addEdge(int u, int v, int cap, int cap2, int cost) {
    edge[e].x = u;
    edge[e].y = v;
    edge[e].cap = cap;
    edge[e].cost = cost;
    edge[e].next = head[u];
    head[u] = e;
    e++;
    edge[e].x = v;
    edge[e].y = u;
    edge[e].cap = cap2;
    edge[e].cost = -cost;
    edge[e].next = head[v];
    head[v] = e;
    e++;
  }
  int vis[100030], q[100030], now[100030];
  bool bfs() {
    memset(vis, -1, sizeof vis);
    vis[source] = 0;
    int ini = 0, qend = 0;
    q[qend++] = source;
    while (ini < qend && vis[sink] == -1) {
      int s = q[ini++];
      int i;
      for (i = head[s]; i != -1; i = edge[i].next) {
        int t = edge[i].y;
        if (vis[t] == -1 && edge[i].cap) {
          vis[t] = vis[s] + 1;
          q[qend++] = t;
        }
      }
    }
    if (vis[sink] != -1)
      return true;
    else
      return false;
  }
  int dfs(int s, int f) {
    if (f == 0) return 0;
    if (s == sink) return f;
    for (int &i = now[s]; i != -1; i = edge[i].next) {
      int t = edge[i].y;
      if (vis[s] + 1 != vis[t]) continue;
      int pushed = dfs(t, ((f) < (edge[i].cap) ? (f) : (edge[i].cap)));
      if (pushed) {
        edge[i].cap -= pushed;
        edge[i ^ 1].cap += pushed;
        return pushed;
      }
    }
    return 0;
  }
  int maxFlow(int highestNumberOfNode, int flow) {
    int res = 0;
    while (1) {
      if (flow == 0) break;
      if (bfs() == false) break;
      int i;
      for (i = 0; i <= highestNumberOfNode; i++) now[i] = head[i];
      while (int pushed = dfs(source, flow)) {
        res += pushed;
        flow -= pushed;
      }
    }
    return res;
  }
  int inq[100030], par[100030], record[100030];
  int minCostFlow(int highestNumberOfNode) {
    int res = 0, i, j, k, fl = 0;
    while (1) {
      for (i = 0; i <= highestNumberOfNode; i++) vis[i] = inf;
      vis[source] = 0;
      deque<int> dq;
      dq.push_back(source);
      while (!dq.empty()) {
        int s = dq.front();
        dq.pop_front();
        inq[s] = 0;
        for (i = head[s]; i != -1; i = edge[i].next) {
          int t = edge[i].y;
          if (edge[i].cap) {
            if (vis[s] + edge[i].cost < vis[t]) {
              vis[t] = vis[s] + edge[i].cost;
              par[t] = s;
              record[t] = i;
              if (inq[t] == 0) {
                inq[t] = 1;
                if (dq.empty() == false && vis[dq.front()] > vis[t])
                  dq.push_front(t);
                else
                  dq.push_back(t);
              }
            }
          }
        }
      }
      if (vis[sink] == inf) break;
      fl++;
      res += vis[sink];
      for (i = sink; i != source; i = par[i]) {
        int t = record[i];
        edge[t].cap--;
        edge[t ^ 1].cap++;
      }
    }
    return res;
  }
} graph;
map<string, int> am;
string br[102];
int ar[102], cr[100005], choice[100005];
int main() {
  br[1] = "S";
  br[2] = "M";
  br[3] = "L";
  br[4] = "XL";
  br[5] = "XXL";
  br[6] = "XXXL";
  am["S"] = 1;
  am["M"] = 2;
  am["L"] = 3;
  am["XL"] = 4;
  am["XXL"] = 5;
  am["XXXL"] = 6;
  int n, flag, x, last = 0;
  string s;
  graph.clear();
  for (int i = 1; i <= 6; i++) {
    scanf("%d", &ar[i]);
  }
  scanf("%d", &n);
  for (int i = 1; i <= 6; i++) {
    graph.addEdge(n + i, n + 7, ar[i], 0, 0);
  }
  for (int i = 1; i <= n; i++) {
    graph.addEdge(0, i, 1, 0, 0);
    int pos = -1;
    flag = 0;
    cin >> s;
    for (int j = 0; j < ((long long)(s).size()); j++) {
      if (s[j] == ',') {
        pos = j;
        flag = 1;
        break;
      }
    }
    if (pos == -1) pos = ((long long)(s).size());
    s = s.substr(0, pos);
    x = am[s];
    choice[i] = x;
    cr[i] = graph.e;
    graph.addEdge(i, n + x, 1, 0, 0);
    if (flag) {
      graph.addEdge(i, n + x + 1, 1, 0, 0);
    }
  }
  graph.source = 0;
  graph.sink = n + 7;
  x = graph.maxFlow(n + 10, 1e9);
  if (x < n) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      if (!graph.edge[cr[i]].cap) {
        cout << br[choice[i]] << "\n";
      } else {
        cout << br[choice[i] + 1] << "\n";
      }
    }
  }
  return 0;
}
