G='#' for s in open(0):T,G=s<'0'and(T,G+[''.join(min(x,c*len(x))for c in s[:-1])for x in T])or(G,[]) G+=map(print,T)