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