#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > G[1000000];
vector<int> R(100001);
map<int, int> V;
map<long long int, long long int> P;
queue<long long int> Q;
void bfs(long long int X, long long int t) {
  if (V[X] == 2) {
    Q.pop();
    return;
  }
  V[X] = 2;
  Q.pop();
  for (unsigned int i = 0; i < G[X].size(); i++) {
    if (V[G[X][i].second] == 0 && G[X][i].first != 0) {
      V[G[X][i].second] = 1;
      P[G[X][i].second] = X;
      if (G[X][i].second == t) return;
      Q.push(G[X][i].second);
    }
  }
  while (!Q.empty()) {
    if (V[t] != 1)
      bfs(Q.front(), t);
    else
      return;
  }
}
long long int update(long long int c, long long int p, long long int small) {
  if (c == p)
    return small;
  else {
    for (unsigned int i = 0; i < G[p].size(); i++) {
      if (G[p][i].second == c) {
        if (small > G[p][i].first) small = G[p][i].first;
        small = update(p, P[p], small);
        G[p][i].first -= small;
        for (unsigned int j = 0; j < G[c].size(); j++) {
          if (G[c][j].second == p) {
            G[c][j].first += small;
            break;
          }
        }
        break;
      }
    }
    return small;
  }
}
long long int MaxFlow(long long int s, long long int t) {
  long long int maxflow = 0;
  do {
    P.clear();
    V.clear();
    V[s] = 1;
    P[s] = s;
    while (!Q.empty()) {
      Q.pop();
    }
    Q.push(s);
    bfs(Q.front(), t);
    if (V[t] == 0)
      break;
    else {
      maxflow += update(t, P[t], 1000000);
    }
  } while (1);
  return maxflow;
}
int main() {
  long long int n;
  long long int x;
  int c, d;
  string s, a;
  for (int i = 1; i <= 6; i++) {
    cin >> x;
    G[100 + i].push_back(make_pair(x, 107));
    G[107].push_back(make_pair(0, 100 + i));
  }
  G[0].push_back(make_pair(0, 1));
  G[0].push_back(make_pair(0, 2));
  G[0].push_back(make_pair(0, 3));
  G[0].push_back(make_pair(0, 4));
  G[0].push_back(make_pair(0, 5));
  G[0].push_back(make_pair(0, 6));
  G[0].push_back(make_pair(0, 12));
  G[0].push_back(make_pair(0, 21));
  G[0].push_back(make_pair(0, 23));
  G[0].push_back(make_pair(0, 32));
  G[0].push_back(make_pair(0, 34));
  G[0].push_back(make_pair(0, 43));
  G[0].push_back(make_pair(0, 45));
  G[0].push_back(make_pair(0, 54));
  G[0].push_back(make_pair(0, 56));
  G[0].push_back(make_pair(0, 65));
  G[1].push_back(make_pair(0, 101));
  G[101].push_back(make_pair(0, 1));
  G[2].push_back(make_pair(0, 102));
  G[102].push_back(make_pair(0, 2));
  G[3].push_back(make_pair(0, 103));
  G[103].push_back(make_pair(0, 3));
  G[4].push_back(make_pair(0, 104));
  G[104].push_back(make_pair(0, 4));
  G[5].push_back(make_pair(0, 105));
  G[105].push_back(make_pair(0, 5));
  G[6].push_back(make_pair(0, 106));
  G[106].push_back(make_pair(0, 6));
  G[12].push_back(make_pair(0, 101));
  G[101].push_back(make_pair(0, 12));
  G[12].push_back(make_pair(0, 102));
  G[102].push_back(make_pair(0, 12));
  G[21].push_back(make_pair(0, 101));
  G[101].push_back(make_pair(0, 21));
  G[21].push_back(make_pair(0, 102));
  G[102].push_back(make_pair(0, 21));
  G[23].push_back(make_pair(0, 102));
  G[102].push_back(make_pair(0, 23));
  G[23].push_back(make_pair(0, 103));
  G[103].push_back(make_pair(0, 23));
  G[32].push_back(make_pair(0, 102));
  G[102].push_back(make_pair(0, 32));
  G[32].push_back(make_pair(0, 103));
  G[103].push_back(make_pair(0, 32));
  G[34].push_back(make_pair(0, 103));
  G[103].push_back(make_pair(0, 34));
  G[34].push_back(make_pair(0, 104));
  G[104].push_back(make_pair(0, 34));
  G[43].push_back(make_pair(0, 103));
  G[103].push_back(make_pair(0, 43));
  G[43].push_back(make_pair(0, 104));
  G[104].push_back(make_pair(0, 43));
  G[45].push_back(make_pair(0, 104));
  G[104].push_back(make_pair(0, 45));
  G[45].push_back(make_pair(0, 105));
  G[105].push_back(make_pair(0, 45));
  G[54].push_back(make_pair(0, 104));
  G[104].push_back(make_pair(0, 54));
  G[54].push_back(make_pair(0, 105));
  G[105].push_back(make_pair(0, 54));
  G[56].push_back(make_pair(0, 105));
  G[105].push_back(make_pair(0, 56));
  G[56].push_back(make_pair(0, 106));
  G[106].push_back(make_pair(0, 56));
  G[65].push_back(make_pair(0, 105));
  G[105].push_back(make_pair(0, 65));
  G[65].push_back(make_pair(0, 106));
  G[106].push_back(make_pair(0, 65));
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    a = "";
    x = 0;
    c = d = 0;
    cin >> s;
    for (int j = 0; j < s.length(); j++) {
      if (s[j] == ',') {
        if (a.compare("S") == 0) {
          x = x * 10 + 1;
        }
        if (a.compare("M") == 0) {
          x = x * 10 + 2;
        }
        if (a.compare("L") == 0) {
          x = x * 10 + 3;
        }
        if (a.compare("XL") == 0) {
          x = x * 10 + 4;
        }
        if (a.compare("XXL") == 0) {
          x = x * 10 + 5;
        }
        if (a.compare("XXXL") == 0) {
          x = x * 10 + 6;
        }
        a = "";
      } else {
        a += s[j];
      }
    }
    if (a.compare("S") == 0) {
      x = x * 10 + 1;
    }
    if (a.compare("M") == 0) {
      x = x * 10 + 2;
    }
    if (a.compare("L") == 0) {
      x = x * 10 + 3;
    }
    if (a.compare("XL") == 0) {
      x = x * 10 + 4;
    }
    if (a.compare("XXL") == 0) {
      x = x * 10 + 5;
    }
    if (a.compare("XXXL") == 0) {
      x = x * 10 + 6;
    }
    c = x % 10;
    d = x / 10;
    for (int j = 0; j < G[x].size(); j++) {
      if ((100 + c) == G[x][j].second || (d + 100) == G[x][j].second) {
        G[x][j].first++;
      }
    }
    R[i] = x;
    for (int j = 0; j < G[0].size(); j++) {
      if (G[0][j].second == x) G[0][j].first++;
    }
  }
  long long int b = MaxFlow(0, 107);
  int y;
  int z;
  if (b == n) {
    cout << "YES" << endl;
    for (long long int i = 1; i <= n; i++) {
      for (int j = 0; j < G[R[i]].size(); j++) {
        y = G[R[i]][j].second;
        for (z = 0; z < G[y].size(); z++) {
          if (G[y][z].second == R[i]) break;
        }
        if (G[y][z].first > 0) {
          if (y == 101) {
            cout << "S" << endl;
            G[y][z].first--;
          }
          if (y == 102) {
            cout << "M" << endl;
            G[y][z].first--;
          }
          if (y == 103) {
            cout << "L" << endl;
            G[y][z].first--;
          }
          if (y == 104) {
            cout << "XL" << endl;
            G[y][z].first--;
          }
          if (y == 105) {
            cout << "XXL" << endl;
            G[y][z].first--;
          }
          if (y == 106) {
            cout << "XXXL" << endl;
            G[y][z].first--;
          }
          break;
        }
      }
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
