#include <bits/stdc++.h>
using namespace std;
string tsize[] = {"S", "M", "L", "XL", "XXL"};
int a[6];
int main() {
  int n = 5;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  int m;
  cin >> m;
  for (int k = 0; k < m; k++) {
    string tshirt;
    cin >> tshirt;
    int tcode = 0;
    for (int i = 0; i < n; i++)
      if (tsize[i] == tshirt) tcode = i;
    for (int i = 0; i < n; i++) {
      if (tcode + i < n && a[tcode + i] > 0) {
        cout << tsize[tcode + i] << endl;
        a[tcode + i]--;
        break;
      }
      if (tcode - i >= 0 && a[tcode - i] > 0) {
        cout << tsize[tcode - i] << endl;
        a[tcode - i]--;
        break;
      }
    }
  }
  return 0;
}
