#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int arr[6], i;
  for (i = 0; i < 5; i++) cin >> arr[i];
  map<int, string> mp;
  map<string, int> mp1;
  mp[0] = "S";
  mp[1] = "M";
  mp[2] = "L";
  mp[3] = "XL";
  mp[4] = "XXL";
  mp1["S"] = 0;
  mp1["M"] = 1;
  mp1["L"] = 2;
  mp1["XL"] = 3;
  mp1["XXL"] = 4;
  int k;
  cin >> k;
  while (k--) {
    string s;
    cin >> s;
    i = mp1[s];
    if (arr[i]) {
      cout << mp[i] << endl;
      arr[i]--;
    } else if (arr[i + 1] && i + 1 < 5) {
      cout << mp[i + 1] << endl;
      arr[i + 1]--;
    } else if (arr[i - 1] && i - 1 >= 0) {
      cout << mp[i - 1] << endl;
      arr[i - 1]--;
    } else if (arr[i + 2] && i + 2 < 5) {
      cout << mp[i + 2] << endl;
      arr[i + 2]--;
    } else if (arr[i - 2] && i - 2 >= 0) {
      cout << mp[i - 2] << endl;
      arr[i - 2]--;
    } else if (arr[i + 3] && i + 3 < 5) {
      cout << mp[i + 3] << endl;
      arr[i + 3]--;
    } else if (arr[i - 3] && i - 3 >= 0) {
      cout << mp[i - 3] << endl;
      arr[i - 3]--;
    } else if (arr[i + 4] && i + 4 < 5) {
      cout << mp[i + 4] << endl;
      arr[i + 4]--;
    } else if (arr[i - 4] && i - 4 >= 0) {
      cout << mp[i - 4] << endl;
      arr[i - 4]--;
    }
  }
}
