#include <bits/stdc++.h>
using namespace std;
char name[5][10];
int s[5];
int mov[10] = {0, 1, -1, 2, -2, 3, -3, 4, -4};
int main() {
  strcpy(name[0], "S");
  strcpy(name[1], "M");
  strcpy(name[2], "L");
  strcpy(name[3], "XL");
  strcpy(name[4], "XXL");
  for (int i = 0; i < 5; i++) scanf("%d", &s[i]);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char ss[10];
    int wh = -1;
    scanf("%s", ss);
    for (int j = 0; j < 5; j++) {
      if (strcmp(name[j], ss) == 0) {
        wh = j;
        break;
      }
    }
    if (wh == -1)
      while (1)
        ;
    for (int j = 0; j < 9; j++) {
      int now = wh + mov[j];
      if (now < 0 || now > 4) continue;
      if (s[now] > 0) {
        s[now]--;
        puts(name[now]);
        break;
      }
    }
  }
  return 0;
}
