while 1: I=raw_input().split();C=map(int,I[1:]);i=0;b=[""] while i=c and"- "!=b[i-c]];b+=[t and min(t,key=len)or"- "] print b[i][:-1]