#include <bits/stdc++.h>
using namespace std;
long long n, d, i, j, a, c, b = 4;
int main() {
  vector<pair<string, int> > v(5);
  v[0].first = "S";
  v[1].first = "M";
  v[2].first = "L";
  v[3].first = "XL";
  v[4].first = "XXL";
  for (i = 0; i < 5; i++) {
    cin >> d;
    v[i].second = d;
  }
  cin >> n;
  vector<string> a1(n);
  for (i = 0; i < n; i++) {
    cin >> a1[i];
  }
  for (j = 0; j < n; j++) {
    for (i = 0; i < 5; i++) {
      if (a1[j] == v[i].first) {
        if (v[i].second != 0) {
          cout << a1[j] << endl;
          v[i].second--;
          break;
        } else {
          b = 1;
          c = 0;
          a = i;
          while (1) {
            if (a + b < 5) {
              if (v[a + b].second != 0) {
                cout << v[a + b].first << endl;
                v[a + b].second--;
                c++;
                break;
              }
            }
            if (a - b >= 0) {
              if (v[a - b].second != 0) {
                cout << v[a - b].first << endl;
                v[a - b].second--;
                c++;
                break;
              }
            }
            b++;
          }
        }
        if (c != 0) break;
      }
    }
  }
}
