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