#include <bits/stdc++.h>
using namespace std;
void openfiles() {}
bool solve() {
  vector<int> shirts(5);
  for (int i = 0; i < 5; i++) {
    scanf("%d ", &shirts[i]);
  }
  map<string, int> mp;
  const char* names[] = {"S", "M", "L", "XL", "XXL"};
  mp["S"] = 0;
  mp["M"] = 1;
  mp["L"] = 2;
  mp["XL"] = 3;
  mp["XXL"] = 4;
  int n;
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) {
    char str[10];
    gets(str);
    int idx = mp[str];
    for (int j = 0; j < 5; j++) {
      if (idx + j < 5 && shirts[idx + j] > 0) {
        printf("%s\n", names[idx + j]);
        shirts[idx + j]--;
        break;
      } else if (idx - j >= 0 && shirts[idx - j] > 0) {
        printf("%s\n", names[idx - j]);
        shirts[idx - j]--;
        break;
      }
    }
  }
  return false;
}
int main() {
  openfiles();
  while (solve())
    ;
  return 0;
}
