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