#include <bits/stdc++.h>
using namespace std;
int main() {
  long long b[100], n, i, j;
  char a[10000];
  cin >> b[0] >> b[1] >> b[2] >> b[3] >> b[4] >> n;
  for (i = 0; i < n; i++) {
    scanf("%s", &a);
    if (a[0] == 'S') {
      if (b[0] != 0) {
        cout << 'S' << endl;
        b[0]--;
      } else {
        if (b[1] != 0) {
          cout << 'M' << endl;
          b[1]--;
        } else {
          if (b[2] != 0) {
            cout << 'L' << endl;
            b[2]--;
          } else {
            if (b[3] != 0) {
              cout << "XL" << endl;
              b[3]--;
            } else {
              cout << "XXL" << endl;
              b[4]--;
            }
          }
        }
      }
    } else if (a[0] == 'M') {
      if (b[1] != 0) {
        cout << 'M' << endl;
        b[1]--;
      } else {
        if (b[2] != 0) {
          cout << 'L' << endl;
          b[2]--;
        } else {
          if (b[0] != 0) {
            cout << 'S' << endl;
            b[0]--;
          } else {
            if (b[3] != 0) {
              cout << "XL" << endl;
              b[3]--;
            } else {
              cout << "XXL" << endl;
              b[4]--;
            }
          }
        }
      }
    } else if (a[0] == 'L') {
      if (b[2] != 0) {
        cout << 'L' << endl;
        b[2]--;
      } else {
        if (b[3] != 0) {
          cout << "XL" << endl;
          b[3]--;
        } else {
          if (b[1] != 0) {
            cout << 'M' << endl;
            b[1]--;
          } else {
            if (b[4] != 0) {
              cout << "XXL" << endl;
              b[4]--;
            } else {
              cout << 'S' << endl;
              b[0]--;
            }
          }
        }
      }
    } else if (a[0] == 'X' && a[1] == 'L') {
      if (b[3] != 0) {
        cout << "XL" << endl;
        b[3]--;
      } else {
        if (b[4] != 0) {
          cout << "XXL" << endl;
          b[4]--;
        } else {
          if (b[2] != 0) {
            cout << 'L' << endl;
            b[2]--;
          } else {
            if (b[1] != 0) {
              cout << 'M' << endl;
              b[1]--;
            } else {
              cout << 'S' << endl;
              b[0]--;
            }
          }
        }
      }
    } else if (a[0] == 'X' && a[1] == 'X' && a[2] == 'L') {
      if (b[4] != 0) {
        cout << "XXL" << endl;
        b[4]--;
      } else {
        if (b[3] != 0) {
          cout << "XL" << endl;
          b[3]--;
        } else {
          if (b[2] != 0) {
            cout << 'L' << endl;
            b[2]--;
          } else {
            if (b[1] != 0) {
              cout << 'M' << endl;
              b[1]--;
            } else {
              cout << 'S' << endl;
              b[0]--;
            }
          }
        }
      }
    }
  }
}
