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