#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
string sizes[] = {"S", "M", "L", "XL", "XXL"};
int id(string a) {
  for (int i = 0; i < 5; ++i)
    if (sizes[i] == a) return i;
}
int next(int a, int b) {
  if (a == b) {
    if (b < 4)
      return ++b;
    else
      return --b;
  }
  if (a + a - b >= 0 && a + a - b < 5) {
    if (b > a)
      return a + a - b;
    else if (a + a >= b - 1 && a + a < b + 4)
      return a + a - b + 1;
  }
  if (b > a)
    return ++b;
  else
    return --b;
}
int main() {
  int cnt[5];
  for (int i = 0; i < 5; ++i) cin >> cnt[i];
  int k;
  cin >> k;
  while (k--) {
    string need;
    cin >> need;
    int pos = id(need);
    int j = pos;
    while (!cnt[j]) {
      j = next(pos, j);
    }
    --cnt[j];
    cout << sizes[j] << '\n';
  }
}
