Codeforces Beta Round #43 B. T-shirts from Sponsor
size = ["S","M","L","XL","XXL"] N = map(int,raw_input().split()) K = input() for i in range(K): c = raw_input() for d in [0,+1,-1,+2,-2,+3,-3,+4,-4]: t = size.index(c)+d if 0<=t<5 and N[t]>0: print size[t] N[t] -= 1 break