#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> m;
  map<string, int> m1;
  map<int, string> m2;
  int a, k, d, e, f;
  string s;
  m1["S"] = 1;
  m1["M"] = 2;
  m1["L"] = 3;
  m1["XL"] = 4;
  m1["XXL"] = 5;
  m2[1] = "S";
  m2[2] = "M";
  m2[3] = "L";
  m2[4] = "XL";
  m2[5] = "XXL";
  for (int i = 1; i <= 5; i++) {
    cin >> a;
    m[i] = a;
  }
  cin >> k;
  for (int j = 1; j <= k; j++) {
    cin >> s;
    d = m1[s];
    if (m[d] >= 1) {
      cout << s << endl;
      m[d]--;
    } else {
      e = m1[s];
      f = m1[s];
      while (true) {
        e++;
        f--;
        if (e <= 5) {
          if (m[e] >= 1) {
            cout << m2[e] << endl;
            m[e]--;
            break;
          }
        }
        if (f >= 1) {
          if (m[f] >= 1) {
            cout << m2[f] << endl;
            m[f]--;
            break;
          }
        }
      }
    }
  }
}
