#include <bits/stdc++.h>
using namespace std;
int n[5], m, ans;
char *sizes[5] = {"S", "M", "L", "XL", "XXL"};
int sol(int i) {
  int c = -1;
  for (int j = 0; j < 5 && c < 0; j++) {
    int a = i + j, b = i - j;
    bool fa = a < 5, fb = b >= 0;
    if (fa && n[a] > 0)
      c = a;
    else if (fb && n[b] > 0)
      c = b;
    else
      c = -1;
  }
  return c;
}
int main() {
  cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4] >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    if (s == "S")
      ans = sol(0);
    else if (s == "M")
      ans = sol(1);
    else if (s == "L")
      ans = sol(2);
    else if (s == "XL")
      ans = sol(3);
    else if (s == "XXL")
      ans = sol(4);
    if (ans < 0 || ans > 4)
      return 666;
    else
      cout << sizes[ans] << endl;
    n[ans]--;
  }
  return 0;
}
