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