#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[20];
  memset(a, 0, sizeof(a));
  for (int i = 0; i < 5; i++) cin >> a[i];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    char str[5];
    cin >> str;
    int tmp;
    if (strcmp(str, "S") == 0) tmp = 0;
    if (strcmp(str, "M") == 0) tmp = 1;
    if (strcmp(str, "L") == 0) tmp = 2;
    if (strcmp(str, "XL") == 0) tmp = 3;
    if (strcmp(str, "XXL") == 0) tmp = 4;
    int index = 0;
    while (1) {
      int tmp1 = max(0, tmp - index);
      int tmp2 = tmp + index;
      if (a[tmp1] == 0 && a[tmp2] == 0) {
        index++;
      } else if (a[tmp2] != 0) {
        index = tmp2;
        break;
      } else {
        index = tmp1;
        break;
      }
    }
    a[index]--;
    if (index == 0) cout << "S" << endl;
    if (index == 1) cout << "M" << endl;
    if (index == 2) cout << "L" << endl;
    if (index == 3) cout << "XL" << endl;
    if (index == 4) cout << "XXL" << endl;
  }
  return 0;
}
