#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int mxn = 1e6 + 9;
using namespace std;
void SoLuTioN() {
  string s, name[5] = {"S", "M", "L", "XL", "XXL"};
  int n, i, j, a[5];
  for (i = 0; i < 5; i++) cin >> a[i];
  cin >> n;
  while (n--) {
    cin >> s;
    for (i = 0; i < 5; i++)
      if (s == name[i]) break;
    for (j = 0; j < 5; j++) {
      if (i + j < 5 && a[i + j] > 0) {
        cout << name[i + j] << endl;
        a[i + j]--;
        break;
      }
      if (i - j >= 0 && a[i - j] > 0) {
        cout << name[i - j] << endl;
        a[i - j]--;
        break;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  T = 1;
  while (T--) {
    SoLuTioN();
  }
  return 0;
}
