#include <bits/stdc++.h>
using namespace std;
int n[6], f, k;
int x[6][6] = {
    {0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5}, {0, 2, 3, 1, 4, 5},
    {0, 3, 4, 2, 5, 1}, {0, 4, 5, 3, 2, 1}, {0, 5, 4, 3, 2, 1},
};
string sf;
int main() {
  cin >> n[1] >> n[2] >> n[3] >> n[4] >> n[5] >> f;
  for (int i = 1; i <= f; i++) {
    cin >> sf;
    if (sf == "S") k = 1;
    if (sf == "M") k = 2;
    if (sf == "L") k = 3;
    if (sf == "XL") k = 4;
    if (sf == "XXL") k = 5;
    for (int j = 1; j <= 5; j++) {
      if (n[x[k][j]] >= 1) {
        switch (x[k][j]) {
          case 1:
            cout << "S\n";
            break;
          case 2:
            cout << "M\n";
            break;
          case 3:
            cout << "L\n";
            break;
          case 4:
            cout << "XL\n";
            break;
          default:
            cout << "XXL\n";
        }
        n[x[k][j]]--;
        break;
      }
    }
  }
}
