#include <bits/stdc++.h>
using namespace std;
string f[5] = {"S", "M", "L", "XL", "XXL"};
int main() {
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    int d;
    if (s == "S") d = 0;
    if (s == "M") d = 1;
    if (s == "L") d = 2;
    if (s == "XL") d = 3;
    if (s == "XXL") d = 4;
    if (a[d] > 0) {
      cout << s << endl;
      a[d]--;
      continue;
    }
    for (int dx = 1; dx <= 5; dx++) {
      if (d + dx < 5 && a[d + dx] > 0) {
        cout << f[d + dx] << endl;
        a[d + dx]--;
        break;
      }
      if (d - dx >= 0 && a[d - dx] > 0) {
        cout << f[d - dx] << endl;
        a[d - dx]--;
        break;
      }
    }
  }
}
