#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  map<string, int> m;
  m["S"] = 0;
  m["M"] = 1;
  m["L"] = 2;
  m["XL"] = 3;
  m["XXL"] = 4;
  string b[5] = {"S", "M", "L", "XL", "XXL"};
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    bool ok = false;
    for (int j = 0; !ok && j < 5; j++) {
      if (m[s] + j < 5 && a[m[s] + j] > 0) {
        cout << b[m[s] + j] << endl;
        a[m[s] + j]--;
        break;
      }
      if (m[s] - j >= 0 && a[m[s] - j] > 0) {
        cout << b[m[s] - j] << endl;
        a[m[s] - j]--;
        break;
      }
    }
  }
  return 0;
}
