#include <bits/stdc++.h>
using namespace std;
int n[5], k, tmp;
string s;
char t[5][4] = {"S", "M", "L", "XL", "XXL"};
int type(string &s) {
  if (s == "S") return 0;
  if (s == "M") return 1;
  if (s == "L") return 2;
  if (s == "XL") return 3;
  return 4;
}
int main() {
  for (int i = 0; i < 5; ++i) cin >> n[i];
  cin >> k;
  for (int i = 0; i < k; ++i) {
    cin >> s;
    tmp = type(s);
    for (int j = 0; j < 5; ++j) {
      if (tmp + j >= 0 && tmp + j < 5 && n[tmp + j] > 0) {
        cout << t[tmp + j] << endl;
        --n[tmp + j];
        break;
      }
      if (tmp - j >= 0 && tmp - j < 5 && n[tmp - j] > 0) {
        cout << t[tmp - j] << endl;
        --n[tmp - j];
        break;
      }
    }
  }
  return 0;
}
