#include <bits/stdc++.h>
using namespace std;
string name[5] = {"S", "M", "L", "XL", "XXL"};
int main() {
  int n[5];
  int K;
  for (int i = 0; i < 5; i++) scanf("%d", n + i);
  scanf("%d", &K);
  for (int i = 0; i < K; ++i) {
    string s;
    cin >> s;
    int j;
    for (j = 0; s != name[j]; ++j)
      ;
    int best = -1000;
    for (int k = 0; k < 5; ++k) {
      if (!n[k]) continue;
      if (abs(k - j) <= abs(best - j)) best = k;
    }
    cout << name[best] << endl;
    --n[best];
  }
  return 0;
}
