#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[10];
map<string, int> mp;
map<int, string> p;
string s;
int main() {
  int i, j, k;
  int n, m;
  for (i = 1; i <= 5; i++) cin >> a[i];
  mp["S"] = 1;
  mp["M"] = 2;
  mp["L"] = 3;
  mp["XL"] = 4;
  mp["XXL"] = 5;
  p[1] = "S";
  p[2] = "M";
  p[3] = "L";
  p[4] = "XL";
  p[5] = "XXL";
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> s;
    if (!a[mp[s]]) {
      if (mp[s] == 3) {
        if (a[4])
          cout << p[4] << endl, a[4]--;
        else if (a[2])
          cout << p[2] << endl, a[2]--;
        else if (a[5])
          cout << p[5] << endl, a[5]--;
        else if (a[1])
          cout << p[1] << endl, a[1]--;
        continue;
      }
      if (mp[s] == 2) {
        if (a[3])
          cout << p[3] << endl, a[3]--;
        else if (a[1])
          cout << p[1] << endl, a[1]--;
        else if (a[4])
          cout << p[4] << endl, a[4]--;
        else if (a[5])
          cout << p[5] << endl, a[5]--;
        continue;
      }
      for (j = mp[s]; j <= 5; j++)
        if (a[j]) {
          cout << p[j] << endl, a[j]--;
          break;
        }
      if (j > 5) {
        for (j = mp[s]; j >= 1; j--)
          if (a[j]) {
            cout << p[j] << endl, a[j]--;
            break;
          }
      }
    } else
      cout << s << endl, a[mp[s]]--;
  }
  return 0;
}
