#include <bits/stdc++.h>
using namespace std;
map<string, int> sz;
string ss[10];
int main() {
  sz["S"] = 1;
  sz["M"] = 2;
  sz["L"] = 3;
  sz["XL"] = 4;
  sz["XXL"] = 5;
  ss[1] = "S";
  ss[2] = "M";
  ss[3] = "L";
  ss[4] = "XL";
  ss[5] = "XXL";
  int a[10] = {};
  for (int i = 1; i <= 5; i++) cin >> a[i];
  int k;
  cin >> k;
  while (k--) {
    string size;
    cin >> size;
    int id = sz[size];
    if (a[id] > 0) {
      cout << ss[id] << endl;
      a[id]--;
    } else if (a[id + 1] > 0) {
      cout << ss[id + 1] << endl;
      a[id + 1]--;
    } else if (a[id - 1] > 0) {
      cout << ss[id - 1] << endl;
      a[id - 1]--;
    } else if (a[id + 2] > 0) {
      cout << ss[id + 2] << endl;
      a[id + 2]--;
    } else if (id > 2 && a[id - 2] > 0) {
      cout << ss[id - 2] << endl;
      a[id - 2]--;
    } else if (a[id + 3] > 0) {
      cout << ss[id + 3] << endl;
      a[id + 3]--;
    } else if (id > 3 && a[id - 3] > 0) {
      cout << ss[id - 3] << endl;
      a[id - 3]--;
    } else if (a[id + 4] > 0) {
      cout << ss[id + 4] << endl;
      a[id + 4]--;
    } else if (id > 4 && a[id - 4] > 0) {
      cout << ss[id - 4] << endl;
      a[id - 4]--;
    }
  }
  return 0;
}
