#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
inline long long pw(long long n, int p) {
  long long ans = 1;
  for (int i = 0; i < p; i++) ans *= n;
  return ans;
}
inline vector<int> ReadVI(int count) {
  vector<int> arrayname(count);
  for (int i = 0; i < int(count); i++) cin >> arrayname[i];
  return arrayname;
};
inline vector<long long> ReadVlong(int count) {
  vector<long long> arrayname(count);
  for (int i = 0; i < int(count); i++) cin >> arrayname[i];
  return arrayname;
};
inline vector<pair<int, int> > ReadVII(int count) {
  vector<pair<int, int> > arrayname(count);
  for (int i = 0; i < int(count); i++) {
    cin >> arrayname[i].first;
    arrayname[i].second = i;
  }
  return arrayname;
};
const int MOD = 1000000007;
const int MAXVALUE = 101;
int main() {
  int f[5];
  cin >> f[0] >> f[1] >> f[2] >> f[3] >> f[4];
  int n;
  cin >> n;
  string a[5] = {"S", "M", "L", "XL", "XXL"};
  int d[9] = {0, 1, -1, 2, -2, 3, -3, 4, -4};
  string ts;
  int t;
  for (int i = 0; i < n; i++) {
    cin >> ts;
    t = 0;
    for (; t < 5; t++)
      if (a[t] == ts) break;
    for (int j = 0; j < 9; j++) {
      int k = t;
      k += d[j];
      if (k < 0 || k > 4) continue;
      if (f[k]) {
        f[k]--;
        cout << a[k] << endl;
        break;
      }
    }
  }
  return 0;
}
