#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1000;
const string s[5] = {"S", "M", "L", "XL", "XXL"};
int strcount[5];
string find_approp_size(string t) {
  int p = 0;
  for (int i = 0; i < 5; i++)
    if (t == s[i]) p = i;
  int u = p;
  int d = p;
  while (true) {
    if (u < 5 && strcount[u]) {
      strcount[u]--;
      return s[u];
    }
    if (d >= 0 && strcount[d]) {
      strcount[d]--;
      return s[d];
    }
    u++;
    d--;
  }
}
int main() {
  for (int i = 0; i < 5; i++) cin >> strcount[i];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string t;
    cin >> t;
    string r = find_approp_size(t);
    cout << r << endl;
  }
  return 0;
}
