#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll i, j, n, t, k, x, cnt = 0, a, b, s, m, l, xl, xxl;
  string str;
  map<string, ll> mp;
  vector<ll> v;
  cin >> s >> m >> l >> xl >> xxl;
  mp["S"] = s;
  mp["M"] = m;
  mp["L"] = l;
  mp["XL"] = xl;
  mp["XXL"] = xxl;
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> str;
    if (str == "S") {
      if (mp["S"]) {
        cout << "S\n";
        mp["S"]--;
      } else if (mp["M"]) {
        cout << "M\n";
        mp["M"]--;
      } else if (mp["L"]) {
        cout << "L\n";
        mp["L"]--;
      } else if (mp["XL"]) {
        cout << "XL\n";
        mp["XL"]--;
      } else if (mp["XXL"]) {
        cout << "XXL\n";
        mp["XXL"]--;
      }
    }
    if (str == "M") {
      if (mp["M"]) {
        cout << "M\n";
        mp["M"]--;
      } else if (mp["L"]) {
        cout << "L\n";
        mp["L"]--;
      } else if (mp["S"]) {
        cout << "S\n";
        mp["S"]--;
      } else if (mp["XL"]) {
        cout << "XL\n";
        mp["XL"]--;
      } else if (mp["XXL"]) {
        cout << "XXL\n";
        mp["XXL"]--;
      }
    }
    if (str == "L") {
      if (mp["L"]) {
        cout << "L\n";
        mp["L"]--;
      } else if (mp["XL"]) {
        cout << "XL\n";
        mp["XL"]--;
      } else if (mp["M"]) {
        cout << "M\n";
        mp["M"]--;
      } else if (mp["XXL"]) {
        cout << "XXL\n";
        mp["XXL"]--;
      } else if (mp["S"]) {
        cout << "S\n";
        mp["S"]--;
      }
    }
    if (str == "XL") {
      if (mp["XL"]) {
        cout << "XL\n";
        mp["XL"]--;
      } else if (mp["XXL"]) {
        cout << "XXL\n";
        mp["XXL"]--;
      } else if (mp["L"]) {
        cout << "L\n";
        mp["L"]--;
      } else if (mp["M"]) {
        cout << "M\n";
        mp["M"]--;
      } else if (mp["S"]) {
        cout << "S\n";
        mp["S"]--;
      }
    }
    if (str == "XXL") {
      if (mp["XXL"]) {
        cout << "XXL\n";
        mp["XXL"]--;
      } else if (mp["XL"]) {
        cout << "XL\n";
        mp["XL"]--;
      } else if (mp["L"]) {
        cout << "L\n";
        mp["L"]--;
      } else if (mp["M"]) {
        cout << "M\n";
        mp["M"]--;
      } else if (mp["S"]) {
        cout << "S\n";
        mp["S"]--;
      }
    }
  }
  return 0;
}
