#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long INF = 1e9 + 5;
const long long mod = 1e9 + 7;
const double pi = 3.1415926536;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  int n, arr[5], j;
  string s, sizes[] = {"S", "M", "L", "XL", "XXL"};
  int i = 5;
  while (i--) cin >> arr[4 - i];
  cin >> n;
  while (n--) {
    cin >> s;
    j = 0;
    while (s != sizes[j]) j++;
    for (int k = 0; k <= 4; k++) {
      if (k + j < 5 && arr[k + j]) {
        arr[k + j]--;
        cout << sizes[k + j] << endl;
        break;
      } else if (j - k >= 0 && arr[j - k]) {
        arr[j - k]--;
        cout << sizes[j - k] << endl;
        break;
      }
    }
  }
  return 0;
}
