#include <bits/stdc++.h>
using namespace std;
int a[10];
void judge(int k) {
  for (int i = 0; i <= 5; i++) {
    int j;
    j = k + i;
    if (j <= 5) {
      if (a[j] != 0) {
        if (j == 1)
          cout << 'S' << endl;
        else if (j == 2)
          cout << 'M' << endl;
        else if (j == 3)
          cout << 'L' << endl;
        else if (j == 4)
          cout << "XL" << endl;
        else if (j == 5)
          cout << "XXL" << endl;
        a[j]--;
        return;
      }
    }
    j = k - i;
    if (j >= 1) {
      if (a[j] != 0) {
        if (j == 1)
          cout << 'S' << endl;
        else if (j == 2)
          cout << 'M' << endl;
        else if (j == 3)
          cout << 'L' << endl;
        else if (j == 4)
          cout << "XL" << endl;
        else if (j == 5)
          cout << "XXL" << endl;
        a[j]--;
        return;
      }
    }
  }
}
int main() {
  int t;
  string s;
  for (int i = 1; i <= 5; i++) cin >> a[i];
  cin >> t;
  while (t--) {
    cin >> s;
    int k;
    if (s[0] == 'S')
      k = 1;
    else if (s[0] == 'M')
      k = 2;
    else if (s[0] == 'L')
      k = 3;
    else if (s.size() == 2)
      k = 4;
    else
      k = 5;
    judge(k);
  }
  return 0;
}
