#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  unordered_map<string, int> mp;
  cin >> mp["S"] >> mp["M"] >> mp["L"] >> mp["XL"] >> mp["XXL"];
  cin >> n;
  string s;
  while (n--) {
    cin >> s;
    if (mp[s]) {
      cout << s << "\n";
      mp[s]--;
    } else if (s == "S") {
      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"]--;
      }
    } else if (s == "M") {
      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"]--;
      }
    } else if (s == "L") {
      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"]--;
      }
    } else if (s == "XL") {
      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"]--;
      }
    } else if (s == "XXL") {
      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;
}
