#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<string, int> val;
  cin >> val["S"];
  cin >> val["M"];
  cin >> val["L"];
  cin >> val["XL"];
  cin >> val["XXL"];
  map<string, vector<string>> neighbours;
  neighbours["S"] = {"S", "M", "L", "XL", "XXL"};
  neighbours["M"] = {"M", "L", "S", "XL", "XXL"};
  neighbours["L"] = {"L", "XL", "M", "XXL", "S"};
  neighbours["XL"] = {"XL", "XXL", "L", "M", "S"};
  neighbours["XXL"] = {"XXL", "XL", "L", "M", "S"};
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    for (int i = 0; i < 5; i++) {
      if (val[neighbours[s][i]] > 0) {
        cout << neighbours[s][i] << "\n";
        val[neighbours[s][i]]--;
        break;
      }
    }
  }
}
