#include <bits/stdc++.h>
const long double pi = 3.1415926535897932384626433832795;
using namespace std;
unsigned long long int leftRotate(unsigned long long int n,
                                  unsigned long long int d) {
  return (n << d) | (n >> (16 - d));
}
unsigned long long int rightRotate(unsigned long long int n,
                                   unsigned long long int d) {
  return (n >> d) | (n << (16 - d));
}
int log2(int x) {
  int res = 0;
  while (x >>= 1) res++;
  return res;
}
long long int comb(long long int n, long long int r) {
  if (r == 0 || r == n) return 1;
  return comb(n - 1, r) + comb(n - 1, r - 1);
}
bool isPowerOfTwo(int n) {
  if (n == 0) return false;
  return (ceil(log2(n)) == floor(log2(n)));
}
long long int inverse(long long int a, long long int m) {
  return 1 < a ? m - inverse(m % a, a) * (m / a) : 1;
}
long long int issorted(long long int arr[], long long int n) {
  if (n == 1 || n == 0) return 1;
  if (arr[n - 1] < arr[n - 2]) return 0;
  return issorted(arr, n - 1);
}
int computeXOR(int n) {
  if (n % 4 == 0) return n;
  if (n % 4 == 1) return 1;
  if (n % 4 == 2)
    return n + 1;
  else
    return 0;
}
long long int count(string s) {
  long long int ans = 1, i, j;
  for (i = 1; i < s.length(); i++) {
    for (j = 0; j < i; j++) {
      if (s[i] == s[j]) break;
    }
    if (i == j) ans++;
  }
  return ans;
}
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
long long int countarray(long long int a[], long long int n) {
  unordered_set<long long int> s;
  for (long long int i = 0; i < n; i++) s.insert(a[i]);
  return s.size();
}
bool check(int N) {
  long long int i;
  if (N & (1 << i))
    return true;
  else
    return false;
}
bool isvowel(char ch) {
  string s = "aeiouAEIOU";
  for (char c : s) {
    if (c == ch) {
      return true;
    }
  }
  return false;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
struct interval {
  int start, end;
};
bool compare(interval x, interval y) { return (x.start < y.start); }
bool isSubstring(string s1, string s2) {
  int M = s1.length();
  int N = s2.length();
  for (int i = 0; i <= N - M; i++) {
    int j;
    for (j = 0; j < M; j++)
      if (s2[i + j] != s1[j]) break;
    if (j == M) return true;
  }
  return false;
}
int seive(int n) {
  bool isprime[n + 1];
  for (int i = 2; i <= n; i++) isprime[i] = true;
  isprime[0] = false;
  isprime[1] = false;
  for (int i = 2; i <= sqrt(n); i++) {
    if (isprime[i] == true) {
      for (int j = i * i; j <= n; j += i) {
        isprime[j] = false;
      }
    }
  }
  int count = 0;
  for (int i = 0; i <= n; i++) {
    if (isprime[i] == true) count++;
  }
  return count;
}
void multiply(int a[2][2], int m[2][2]) {
  int him[2][2];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      him[i][j] = 0;
      for (int k = 0; k < 2; k++) {
        him[i][j] += (a[i][k] * m[k][j]);
      }
    }
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      a[i][j] = him[i][j];
    }
  }
}
void power(int a[2][2], int n) {
  if (n == 0 || n == 1) return;
  power(a, n / 2);
  multiply(a, a);
  if (n % 2 != 0) {
    int m[2][2] = {{1, 1}, {1, 0}};
    multiply(a, m);
  }
}
int fib(int n) {
  int a[2][2] = {{1, 1}, {1, 0}};
  if (n == 0) return 0;
  power(a, n - 1);
  return a[0][0];
}
int factmod(int n, int p) {
  int res = 1;
  while (n > 1) {
    res = (res * ((n / p) % 2 ? p - 1 : 1)) % p;
    for (int i = 2; i <= (n % p); i++) res = (res * i) % p;
    n /= p;
  }
  return res % p;
}
long long int modularexponentiation(long long int a, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = ((res % 1000000007) * (a % 1000000007)) % 1000000007;
    n /= 2;
    a = ((a % 1000000007) * (a % 1000000007)) % 1000000007;
  }
  return res;
}
long long int largest_power(long long int N) {
  N = N | (N >> 1);
  N = N | (N >> 2);
  N = N | (N >> 4);
  N = N | (N >> 8);
  N = N | (N >> 16);
  return (N + 1) >> 1;
}
bool alternate(long long int n) {
  long long int i;
  if ((n ^ (n >> 1)) == (pow(2, i) - 1)) return true;
  return false;
}
long long int countDivisors(long long int n) {
  long long int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
int highestpowerof2(int n) { return (n & (~(n - 1))); }
void lowertoupper(char ch) {
  ch = ch & '_';
  cout << ch << " ";
}
void uppertolower(char ch) {
  ch = ch | ' ';
  cout << ch << " ";
}
long long int primecounter(long long int l, long long int r) {
  long long int fact = 1, count = 0;
  for (long long int i = l; i <= r; i++) {
    if (((fact - i) % ((1LL << i) - 1)) == 0) count++;
    fact *= ((1LL << i) - 1);
  }
  return count;
}
long long int counteprime(long long int l, long long int r) {
  long long int count = 0, i, j;
  for (i = l; i <= r; i++) {
    for (j = 2; j <= (i / j); j++) {
      if (!(i % j)) break;
    }
    if (j > (i / j)) count++;
  }
  return count;
}
void pairsort(int a[], char b[], int n) {
  pair<int, char> pairt[n];
  for (int i = 0; i < n; i++) {
    pairt[i].first = a[i];
    pairt[i].second = b[i];
  }
  sort(pairt, pairt + n);
  for (int i = 0; i < n; i++) {
    a[i] = pairt[i].first;
    b[i] = pairt[i].second;
  }
}
long long int fibo(long long int n) {
  long double him = (1 + sqrt(5)) / 2;
  return round(pow(him, n) / sqrt(5));
}
long long int binToDec(string c) {
  long long int count = 0;
  for (long long int i = 0; i < c.length(); i++) {
    if (c[i] == '1') {
      long long int val = 1;
      for (long long int j = 0; j < i; j++) {
        val *= 2;
      }
      count += val;
    }
  }
  return count;
}
void rev(int a[], int n) {
  for (long long int i = 0, j = n - 1; i < j; i++, j--) {
    swap(a[i], a[j]);
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string a[6];
  long long int ar[5];
  for (int i = 0; i < 5; i++) cin >> ar[i];
  a[0] = "S", a[1] = "M", a[2] = "L", a[3] = "XL", a[4] = "XXL";
  map<string, long long int> make_pair;
  for (long long int i = 0; i < 5; i++) make_pair[a[i]] = i;
  long long int q;
  cin >> q;
  while (q--) {
    string s;
    cin >> s;
    long long int z = make_pair[s];
    for (long long int i = 0; i < 5; i++) {
      if ((z + i) < 5 && ar[z + i] > 0) {
        cout << a[z + i] << endl;
        ar[z + i]--;
        break;
      }
      if ((z - i) >= 0 && ar[z - i] > 0) {
        cout << a[z - i] << endl;
        ar[z - i]--;
        break;
      }
    }
  }
}
