#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
char Tsh[5][5] = {"S", "M", "L", "XL", "XXL"};
int num[5], p[maxn];
int ans[maxn];
int getid(char a[]) {
  for (int i = 0; i < 5; i++)
    if (strcmp(a, Tsh[i]) == 0) return i;
  return 0;
}
int main() {
  int i, k, j;
  memset(ans, -1, sizeof(ans));
  char str[5];
  for (i = 0; i < 5; i++) cin >> num[i];
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> str;
    p[i] = getid(str);
  }
  for (i = 0; i < k; i++) {
    if (num[p[i]])
      ans[i] = p[i], num[p[i]]--;
    else {
      j = 1;
      while (p[i] + j < 5 && p[i] - j >= 0) {
        if (num[p[i] + j]) {
          ans[i] = p[i] + j, num[p[i] + j]--;
          break;
        }
        if (num[p[i] - j]) {
          ans[i] = p[i] - j, num[p[i] - j]--;
          break;
        }
        j++;
      }
      while (p[i] + j < 5 && ans[i] == -1) {
        if (num[p[i] + j]) {
          ans[i] = p[i] + j, num[p[i] + j]--;
          break;
        }
        j++;
      }
      while (p[i] - j >= 0 && ans[i] == -1) {
        if (num[p[i] - j]) {
          ans[i] = p[i] - j, num[p[i] - j]--;
          break;
        }
        j++;
      }
    }
  }
  for (i = 0; i < k; i++) cout << Tsh[ans[i]] << endl;
  return 0;
}
