#include <bits/stdc++.h>
using namespace std;
int main() {
  int mas[5];
  for (int i = 0; i < 5; i++) {
    cin >> mas[i];
  }
  int n;
  cin >> n;
  string s;
  getline(cin, s);
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    if (s == "S") {
      if (mas[0] != 0) {
        mas[0]--;
        cout << "S\n";
        continue;
      } else {
        s = "M";
      }
    }
    if (s == "M") {
      if (mas[1] != 0) {
        mas[1]--;
        cout << "M\n";
        continue;
      } else {
        if (mas[2] != 0) {
          mas[2]--;
          cout << "L\n";
          continue;
        } else if (mas[0] != 0) {
          mas[0]--;
          cout << "S\n";
          continue;
        } else {
          s = "L";
        }
      }
    }
    if (s == "L") {
      if (mas[2] != 0) {
        mas[2]--;
        cout << "L\n";
        continue;
      } else {
        if (mas[3] != 0) {
          mas[3]--;
          cout << "XL\n";
          continue;
        } else if (mas[1] != 0) {
          mas[1]--;
          cout << "M\n";
          continue;
        } else if (mas[4] != 0) {
          mas[4]--;
          cout << "XXL\n";
          continue;
        } else if (mas[0] != 0) {
          mas[0]--;
          cout << "S\n";
          continue;
        }
      }
    }
    if (s == "XL") {
      if (mas[3] != 0) {
        mas[3]--;
        cout << "XL\n";
        continue;
      } else {
        if (mas[4] != 0) {
          mas[4]--;
          cout << "XXL\n";
          continue;
        } else if (mas[2] != 0) {
          mas[2]--;
          cout << "L\n";
          continue;
        } else if (mas[1] != 0) {
          mas[1]--;
          cout << "M\n";
          continue;
        } else if (mas[0] != 0) {
          mas[0]--;
          cout << "S\n";
          continue;
        }
      }
    }
    if (s == "XXL") {
      if (mas[4] != 0) {
        mas[4]--;
        cout << "XXL\n";
        continue;
      } else {
        if (mas[3] != 0) {
          mas[3]--;
          cout << "XL\n";
          continue;
        } else if (mas[2] != 0) {
          mas[2]--;
          cout << "L\n";
          continue;
        } else if (mas[1] != 0) {
          mas[1]--;
          cout << "M\n";
          continue;
        } else if (mas[0] != 0) {
          mas[0]--;
          cout << "S\n";
          continue;
        }
      }
    }
  }
  return 0;
}
