#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main() {
  int i, j, k;
  int arr[5];
  for (i = 0; i < 5; i++) cin >> arr[i];
  vector<int> vec[5];
  vector<string> name;
  name.push_back("S");
  name.push_back("M");
  name.push_back("L");
  name.push_back("XL");
  name.push_back("XXL");
  for (i = 0; i < 5; i++) {
    vec[i].push_back(i);
    for (j = 1; j < 5; j++) {
      int a = i + j;
      if (a < 5) vec[i].push_back(a);
      a = i - j;
      if (a >= 0) vec[i].push_back(a);
    }
  }
  map<string, int> ind;
  for (i = 0; i < 5; i++) ind[name[i]] = i;
  int N;
  cin >> N;
  for (i = 0; i < N; i++) {
    string s;
    cin >> s;
    int indice = ind[s];
    for (j = 0; j < 5; j++) {
      if (arr[vec[indice][j]]) {
        arr[vec[indice][j]]--;
        cout << name[vec[indice][j]] << endl;
        break;
      }
    }
  }
  return 0;
}
