#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a[5];
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
  }
  map<string, int> id;
  id["S"] = 0;
  id["M"] = 1;
  id["L"] = 2;
  id["XL"] = 3;
  id["XXL"] = 4;
  vector<string> vct = {"S", "M", "L", "XL", "XXL"};
  int q;
  cin >> q;
  while (q--) {
    string s;
    cin >> s;
    int x = id[s];
    for (int i = 0;; ++i) {
      if (x + i < 5 && a[x + i]) {
        cout << vct[i + x] << '\n';
        --a[i + x];
        break;
      }
      if (x - i >= 0 && a[x - i]) {
        cout << vct[x - i] << '\n';
        --a[x - i];
        break;
      }
    }
  }
}
