#include <bits/stdc++.h>
using namespace std;
struct no {
  int r;
  int l;
  int p;
};
int main() {
  int s[5];
  char ss[5][5] = {"S", "M", "L", "XL", "XXL"};
  int sss[5][5] = {0, 1, 2, 3, 4, 1, 2, 0, 3, 4, 2, 3, 1,
                   4, 0, 3, 4, 2, 1, 0, 4, 3, 2, 1, 0};
  for (int i = 0; i < 5; i++) cin >> s[i];
  int n;
  cin >> n;
  char ff[5];
  getchar();
  for (int i = 0; i < n; i++) {
    gets(ff);
    int yy;
    for (int j = 0; j < 5; j++)
      if (strcmp(ff, ss[j]) == 0) {
        yy = j;
        break;
      }
    for (int k = 0; k < 5; k++) {
      if (s[sss[yy][k]] > 0) {
        cout << ss[sss[yy][k]] << endl;
        s[sss[yy][k]]--;
        break;
      }
    }
  }
  return 0;
}
