#include <bits/stdc++.h>
using namespace std;
int n, m;
int s, t;
struct Edge {
  int from, to, next;
  int cap, flow;
  void get(int u, int a, int b, int c, int d) {
    from = u;
    to = a;
    next = b;
    cap = c;
    flow = d;
  }
} edge[100050 << 4];
int tol;
int head[100050];
int gap[100050], dep[100050], pre[100050], cur[100050];
void init() {
  tol = 0;
  memset(head, -1, sizeof head);
}
void add_edge(int u, int v, int w, int rw = 0) {
  edge[tol].get(u, v, head[u], w, 0);
  head[u] = tol++;
  edge[tol].get(v, u, head[v], rw, 0);
  head[v] = tol++;
}
int sap(int start, int end, int N) {
  memset(gap, 0, sizeof gap);
  memset(dep, 0, sizeof dep);
  memcpy(cur, head, sizeof head);
  int u = start;
  pre[u] = -1;
  gap[0] = N;
  int ans = 0;
  while (dep[start] < N) {
    if (u == end) {
      int Min = 1e7;
      for (int i = pre[u]; i != -1; i = pre[edge[i ^ 1].to])
        if (Min > edge[i].cap - edge[i].flow) Min = edge[i].cap - edge[i].flow;
      for (int i = pre[u]; i != -1; i = pre[edge[i ^ 1].to]) {
        edge[i].flow += Min;
        edge[i ^ 1].flow -= Min;
      }
      u = start;
      ans += Min;
      continue;
    }
    bool flag = false;
    int v;
    for (int i = cur[u]; i != -1; i = edge[i].next) {
      v = edge[i].to;
      if (edge[i].cap - edge[i].flow && dep[v] + 1 == dep[u]) {
        flag = true;
        cur[u] = pre[v] = i;
        break;
      }
    }
    if (flag) {
      u = v;
      continue;
    }
    int Min = N;
    for (int i = head[u]; i != -1; i = edge[i].next)
      if (edge[i].cap - edge[i].flow && dep[edge[i].to] < Min) {
        Min = dep[edge[i].to];
        cur[u] = i;
      }
    gap[dep[u]]--;
    if (!gap[dep[u]]) return ans;
    dep[u] = Min + 1;
    gap[dep[u]]++;
    if (u != start) u = edge[pre[u] ^ 1].to;
  }
  return ans;
}
int a[11];
char str[100050];
void add(int now) {
  int len = strlen(str);
  int j;
  for (int i = 0; i < len; i = j + 1) {
    j = i;
    while (str[j] != ',' && str[j] != 0) j++;
    if (str[i] == 'S') {
      add_edge(now, n + 1, 1);
    } else if (str[i] == 'M') {
      add_edge(now, n + 2, 1);
    } else if (str[i] == 'L') {
      add_edge(now, n + 3, 1);
    } else {
      int more = j - i;
      more += 2;
      add_edge(now, more + n, 1);
    }
  }
}
void print(int num) {
  num -= n;
  if (num == 1) {
    cout << "S" << endl;
  } else if (num == 2)
    cout << "M" << endl;
  else if (num == 3)
    cout << "L" << endl;
  else if (num == 4)
    cout << "XL" << endl;
  else if (num == 5)
    cout << "XXL" << endl;
  else
    cout << "XXXL" << endl;
}
int main() {
  for (int i = 1; i <= 6; i++) {
    cin >> a[i];
  }
  cin >> n;
  int N;
  s = 0, t = n + 7, N = t + 1;
  init();
  for (int i = 1; i <= 6; i++) {
    add_edge(n + i, t, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    cin >> str;
    add_edge(s, i, 1);
    add(i);
  }
  int ans = sap(s, t, N);
  if (ans != n) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (int u = 1; u <= n; u++) {
    for (int i = head[u]; i != -1; i = edge[i].next) {
      int v = edge[i].to;
      if (v > n && v <= n + 6 && edge[i].flow) {
        print(v);
      }
    }
  }
  return 0;
}
