#include <bits/stdc++.h>
using namespace std;
int n[6];
string t[6] = {"", "S", "M", "L", "XL", "XXL"};
int main() {
  string s;
  memset(n, 0, sizeof(n));
  for (int i = 1; i <= 5; ++i) {
    scanf("%d", &n[i]);
  }
  int k = 0, idx = 0;
  map<string, int> sMap;
  for (int i = 1; i <= 5; ++i) {
    sMap[t[i]] = i;
  }
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    cin >> s;
    idx = sMap[s];
    int cur = 0;
    while (cur < 5) {
      int tmp = idx + cur;
      if (tmp <= 5 && n[tmp] != 0) {
        n[tmp] -= 1;
        cout << t[tmp] << endl;
        break;
      } else {
        tmp = idx - cur;
        if (tmp >= 1 && n[tmp] != 0) {
          n[tmp] -= 1;
          cout << t[tmp] << endl;
          break;
        }
        ++cur;
      }
    }
  }
  return 0;
}
