#include <bits/stdc++.h>
using namespace std;
map<string, int> Ts;
string size[101] = {"S", "M", "L", "XL", "XXL"};
inline int to_size(string s) {
  for (int i = 0; i < 5; ++i) {
    if (s == size[i]) return i;
  }
}
int main() {
  int a[11], k;
  string pe[10010];
  for (int i = 0; i < 5; ++i) cin >> a[i];
  for (int i = 0; i < 5; ++i) {
    Ts[size[i]] = a[i];
  }
  cin >> k;
  for (int i = 0; i < k; ++i) cin >> pe[i];
  for (int i = 0; i < k; ++i) {
    int pe1 = to_size(pe[i]);
    for (int j = 0; j <= 4; ++j) {
      if (pe1 + j <= 4) {
        if (Ts[size[pe1 + j]] > 0) {
          Ts[size[pe1 + j]]--;
          cout << size[pe1 + j] << endl;
          break;
        }
      }
      if (pe1 - j >= 0) {
        if (Ts[size[pe1 - j]] > 0) {
          Ts[size[pe1 - j]]--;
          cout << size[pe1 - j] << endl;
          break;
        }
      }
    }
  }
  return 0;
}
