#include <bits/stdc++.h>
using namespace std;
int k;
map<string, int> si;
map<int, string> is;
map<int, int> m;
string st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> k;
  m[0] = k;
  cin >> k;
  m[1] = k;
  cin >> k;
  m[2] = k;
  cin >> k;
  m[3] = k;
  cin >> k;
  m[4] = k;
  si["S"] = 0;
  si["M"] = 1;
  si["L"] = 2;
  si["XL"] = 3;
  si["XXL"] = 4;
  is[0] = "S";
  is[1] = "M";
  is[2] = "L";
  is[3] = "XL";
  is[4] = "XXL";
  cin >> k;
  while (k--) {
    cin >> st;
    int to = si[st];
    if (m[to] > 0) {
      cout << st << endl;
      --m[to];
    } else if (m.count(to + 1) && m[to + 1] > 0) {
      cout << is[to + 1] << endl;
      --m[to + 1];
    } else if (m.count(to - 1) && m[to - 1] > 0) {
      cout << is[to - 1] << endl;
      --m[to - 1];
    } else if (m.count(to + 2) && m[to + 2] > 0) {
      cout << is[to + 2] << endl;
      --m[to + 2];
    } else if (m.count(to - 2) && m[to - 2] > 0) {
      cout << is[to - 2] << endl;
      --m[to - 2];
    } else if (m.count(to + 3) && m[to + 3] > 0) {
      cout << is[to + 3] << endl;
      --m[to + 3];
    } else if (m.count(to - 3) && m[to - 3] > 0) {
      cout << is[to - 3] << endl;
      --m[to - 3];
    } else if (m.count(to + 4) && m[to + 4] > 0) {
      cout << is[to + 4] << endl;
      --m[to + 4];
    } else if (m.count(to - 4) && m[to - 4] > 0) {
      cout << is[to - 4] << endl;
      --m[to - 4];
    }
  }
}
