#include <bits/stdc++.h>
using namespace std;
string s[5] = {"S", "M", "L", "XL", "XXL"};
int f(string t) {
  for (int i = 0; i < 5; i++)
    if (s[i] == t) return i;
}
int main() {
  int n[5];
  for (int i = 0; i < 5; i++) cin >> n[i];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string t;
    cin >> t;
    int pos = f(t);
    if (n[pos] > 0) {
      cout << s[pos] << endl;
      n[pos]--;
      continue;
    }
    int d = 1;
    while (1) {
      if (pos + d >= 0 && pos + d < 5 && n[pos + d] > 0) {
        cout << s[pos + d] << endl;
        n[pos + d]--;
        break;
      }
      if (d > 0)
        d = -d;
      else
        d = -d + 1;
    }
  }
  return 0;
}
