#include <bits/stdc++.h>
using namespace std;
long long int _xor(long long int a, long long int b) { return a ^ b; }
long long int _and(long long int a, long long int b) { return a & b; }
long long int _or(long long int a, long long int b) { return a | b; }
long long int _not(long long int a) { return ~a; }
long long int ai[1000], pi[2005];
int main() {
  long long int b, c = 0, x, y, z, t, i, j, k, l1, l2, m, n, c1 = 1e18,
                   c2 = 1e18, q, f = 0;
  map<string, long long int> number, pos;
  map<long long int, string> look;
  scanf("%lld", &number["S"]);
  scanf("%lld", &number["M"]);
  scanf("%lld", &number["L"]);
  scanf("%lld", &number["XL"]);
  scanf("%lld", &number["XXL"]);
  pos["S"] = 0, pos["M"] = 1, pos["L"] = 2, pos["XL"] = 3, pos["XXL"] = 4;
  look[0] = "S", look[1] = "M", look[2] = "L", look[3] = "XL", look[4] = "XXL";
  scanf("%lld", &n);
  string str;
  for (i = 0; i < n; i++) {
    cin >> str;
    for (j = 0; j < 5; j++) {
      if (pos[str] == j) {
        l1 = j;
        break;
      }
    }
    if (number[str] > 0) {
      cout << str << '\n';
      number[str]--;
    } else {
      string str1, str2;
      for (j = l1 + 1; j < 5; j++) {
        if (number[look[j]] > 0) {
          str1 = look[j];
          c1 = j;
          break;
        }
      }
      for (j = l1 - 1; j >= 0; j--) {
        if (number[look[j]] > 0) {
          str2 = look[j];
          c2 = j;
          break;
        }
      }
      if (abs(c1 - l1) > abs(l1 - c2)) {
        cout << str2 << '\n';
        number[str2]--;
      } else if (abs(c1 - l1) < abs(l1 - c2)) {
        cout << str1 << '\n';
        number[str1]--;
      } else if (abs(c1 - l1) == abs(l1 - c2)) {
        cout << str1 << '\n';
        number[str1]--;
      }
      c1 = 1e18;
      c2 = 1e18;
    }
  }
  return 0;
}
