#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, m, l, xl, xxl, t;
  cin >> s >> m >> l >> xl >> xxl;
  cin >> t;
  while (t--) {
    string q;
    cin >> q;
    if (q == "S") {
      if (s > 0) {
        s--;
        cout << "S" << endl;
      } else if (m > 0) {
        m--;
        cout << "M" << endl;
      } else if (l > 0) {
        l--;
        cout << "L" << endl;
      } else if (xl > 0) {
        xl--;
        cout << "XL" << endl;
      } else {
        xxl--;
        cout << "XXL" << endl;
      }
    }
    if (q == "M") {
      if (m > 0) {
        m--;
        cout << "M" << endl;
      } else if (l > 0) {
        l--;
        cout << "L" << endl;
      } else if (s > 0) {
        s--;
        cout << "S" << endl;
      } else if (xl > 0) {
        xl--;
        cout << "XL" << endl;
      } else {
        xxl--;
        cout << "XXL" << endl;
      }
    }
    if (q == "L") {
      if (l > 0) {
        l--;
        cout << "L" << endl;
      } else if (xl > 0) {
        xl--;
        cout << "XL" << endl;
      } else if (m > 0) {
        m--;
        cout << "M" << endl;
      } else if (xxl > 0) {
        xxl--;
        cout << "XXL" << endl;
      } else {
        s--;
        cout << "S" << endl;
      }
    }
    if (q == "XL") {
      if (xl > 0) {
        xl--;
        cout << "XL" << endl;
      } else if (xxl > 0) {
        xxl--;
        cout << "XXL" << endl;
      } else if (l > 0) {
        l--;
        cout << "L" << endl;
      } else if (m > 0) {
        m--;
        cout << "M" << endl;
      } else {
        s--;
        cout << "S" << endl;
      }
    }
    if (q == "XXL") {
      if (xxl > 0) {
        xxl--;
        cout << "XXL" << endl;
      } else if (xl > 0) {
        xl--;
        cout << "XL" << endl;
      } else if (l > 0) {
        l--;
        cout << "L" << endl;
      } else if (m > 0) {
        m--;
        cout << "M" << endl;
      } else {
        s--;
        cout << "S" << endl;
      }
    }
  }
  return 0;
}
