#include <bits/stdc++.h>
using namespace std;
int ukuran[5];
string sizee[5]{"S", "M", "L", "XL", "XXL"};
vector<string> dkasih;
int x;
int main() {
  for (int i = 0; i < 5; i++) {
    cin >> ukuran[i];
  }
  cin >> x;
  int p, o;
  string temp;
  for (int i = 0; i < x; i++) {
    cin >> temp;
    for (int j = 0; j < 5; j++) {
      if (temp == sizee[j] && ukuran[j] != 0) {
        dkasih.push_back(sizee[j]);
        ukuran[j]--;
        break;
      } else if (temp == sizee[j] && ukuran[j] == 0) {
        p = j, o = j;
        while (true) {
          if (p < 5 && ukuran[p] == 0) {
            p++;
            if (ukuran[p]) break;
          }
          if (o > 0 && ukuran[o] == 0) {
            o--;
            if (ukuran[o]) break;
          }
        }
        if (ukuran[p] > 0) {
          dkasih.push_back(sizee[p]);
          ukuran[p]--;
        } else {
          dkasih.push_back(sizee[o]);
          ukuran[o]--;
        }
        break;
      }
    }
  }
  for (int i = 0; i < dkasih.size(); i++) cout << dkasih[i] << endl;
  return 0;
}
