#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[10], ans[2000] = {};
  for (int i = 0; i < 5; i++) cin >> a[i];
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int o = 0;
    cin >> s;
    if (s == "M")
      o = 1;
    else if (s == "L")
      o = 2;
    else if (s == "XL")
      o = 3;
    else if (s == "XXL")
      o = 4;
    int k = o, l = o;
    for (k = o; k <= 4 && !a[k]; k++)
      ;
    for (l = o; l >= 0 && !a[l]; l--)
      ;
    if ((k - o <= o - l && k != 5) || l == -1) {
      ans[i] = k;
      a[k]--;
    } else {
      ans[i] = l;
      a[l]--;
    }
  }
  for (int i = 0; i < n; i++) {
    int o = ans[i];
    if (o == 0)
      cout << 'S' << " ";
    else if (o == 1)
      cout << 'M' << " ";
    else if (o == 2)
      cout << 'L' << " ";
    else if (o == 3)
      cout << "XL"
           << " ";
    else
      cout << "XXL ";
  }
  cout << endl;
  return 0;
}
