#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vsi = vector<pair<str, ll> >;
using mii = map<ll, ll>;
using li = list<ll>;
void solve() {
  ll s, m, l, xl, xxl;
  cin >> s >> m >> l >> xl >> xxl;
  ll k;
  cin >> k;
  for (ll x = 0; x < k; ++x) {
    str st;
    cin >> st;
    if (st == "S") {
      if (s > 0) {
        cout << "S" << endl;
        --s;
      } else if (m > 0) {
        cout << "M" << endl;
        --m;
      } else if (l > 0) {
        cout << "L" << endl;
        --l;
      } else if (xl > 0) {
        cout << "XL" << endl;
        --xl;
      } else if (xxl > 0) {
        cout << "XXL" << endl;
        --xxl;
      }
    } else if (st == "M") {
      if (m > 0) {
        cout << "M" << endl;
        --m;
      } else if (l > 0) {
        cout << "L" << endl;
        --l;
      } else if (s > 0) {
        cout << "S" << endl;
        --s;
      } else if (xl > 0) {
        cout << "XL" << endl;
        --xl;
      } else if (xxl > 0) {
        cout << "XXL" << endl;
        --xxl;
      }
    } else if (st == "L") {
      if (l > 0) {
        cout << "L" << endl;
        --l;
      } else if (xl > 0) {
        cout << "XL" << endl;
        --xl;
      } else if (m > 0) {
        cout << "M" << endl;
        --m;
      } else if (xxl > 0) {
        cout << "XXL" << endl;
        --xxl;
      } else if (s > 0) {
        cout << "S" << endl;
        --s;
      }
    }
    if (st == "XL") {
      if (xl > 0) {
        cout << "XL" << endl;
        --xl;
      } else if (xxl > 0) {
        cout << "XXL" << endl;
        --xxl;
      } else if (l > 0) {
        cout << "L" << endl;
        --l;
      } else if (m > 0) {
        cout << "M" << endl;
        --m;
      } else if (s > 0) {
        cout << "S" << endl;
        --s;
      }
    } else if (st == "XXL") {
      if (xxl > 0) {
        cout << "XXL" << endl;
        --xxl;
      } else if (xl > 0) {
        cout << "XL" << endl;
        --xl;
      } else if (l > 0) {
        cout << "L" << endl;
        --l;
      } else if (m > 0) {
        cout << "M" << endl;
        --m;
      } else if (s > 0) {
        cout << "S" << endl;
        --s;
      }
    }
  }
}
int main() {
  solve();
  return 0;
}
