#include <bits/stdc++.h>
using namespace std;
int main() {
  int sizes[5];
  for (int i = 0; i < 5; i++) {
    cin >> sizes[i];
  }
  int n;
  cin >> n;
  string m[5];
  m[0] = "S";
  m[1] = "M";
  m[2] = "L";
  m[3] = "XL";
  m[4] = "XXL";
  int winners[n];
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    for (int j = 0; j < 5; j++) {
      if (m[j] == a) {
        winners[i] = j;
      }
    }
  }
  vector<int> searchOrder;
  for (int i = 0; i < 5; i++) {
    searchOrder.push_back(i);
    searchOrder.push_back(-i);
  }
  vector<int> results;
  for (int i = 0; i < n; i++) {
    bool found = false;
    for (int j = 0; j < searchOrder.size(); j++) {
      int a = winners[i] + searchOrder.at(j);
      if (!found && a >= 0 && a < 5) {
        if (sizes[a] > 0) {
          sizes[a]--;
          results.push_back(a);
          found = true;
        }
      }
    }
  }
  for (int i = 0; i < results.size(); i++) {
    cout << m[results.at(i)] << "\n";
  }
}
