#include <bits/stdc++.h>
using namespace std;
map<string, int> shirt;
string op[5] = {"S", "M", "L", "XL", "XXL"};
int dx[9] = {0, 1, -1, 2, -2, 3, -3, 4, -4};
int n, x, numshirts[5];
string s;
int main() {
  for (int i = 0; i < 5; i++) {
    shirt[op[i]] = i;
    cin >> numshirts[i];
  }
  cin >> n;
  while (n--) {
    cin >> s;
    x = shirt[s];
    for (int i = 0; i < 9; i++) {
      if (x + dx[i] >= 0 && x + dx[i] < 5 && numshirts[x + dx[i]] > 0) {
        cout << op[x + dx[i]] << endl;
        numshirts[x + dx[i]]--;
        break;
      }
    }
  }
}
