#include <bits/stdc++.h>   using namespace std;   int N[5];   int K;   int getChoice(int choice) {     if (N[choice]) return choice;     for (int i = 1; true; i++) {       if (choice + i < 5 && N[choice + i]) return choice + i;       if (choice - i >= 0 && N[choice - i]) return choice - i;     }   }   int main() {     for (int i = 0; i < 5; i++) cin >> N[i];     cin >> K;     map<string, int> strToInt;     strToInt[ S ] = 0;     strToInt[ M ] = 1;     strToInt[ L ] = 2;     strToInt[ XL ] = 3;     strToInt[ XXL ] = 4;     map<int, string> intToStr;     intToStr[0] =  S ;     intToStr[1] =  M ;     intToStr[2] =  L ;     intToStr[3] =  XL ;     intToStr[4] =  XXL ;     string temp;     for (int i = 0; i < K; i++) {       cin.ignore(5,   n );       cin >> temp;       int choice = strToInt[temp];       int willGet = getChoice(choice);       N[willGet]--;       cout << intToStr[willGet] <<   n ;     }     return 0;   }   