#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 5;
int n, t[5];
string a[maxn], c[5] = {"S", "M", "L", "XL", "XXL"};
int main() {
  int x = 0, y = 0;
  cin >> t[0] >> t[1] >> t[2] >> t[3] >> t[4] >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++)
      if (a[i] == c[j]) {
        x = j;
        y = j;
        while (t[x] == 0 && t[y] == 0) {
          if (x < 4) x++;
          if (y > 0) y--;
        }
        if (t[x] > 0)
          break;
        else {
          x = y;
          break;
        }
      }
    t[x]--;
    cout << c[x] << endl;
  }
  return 0;
}
