S, T = input().split() A = list(map(int,input().split())) s = len(S) t = len(T) r = t % s ans = [list() for i in range(N)] for i in range(N): if A[i] % s == 0: for i in range(A[i] // s): ans[i].append(S) else: p = A[i] % s while p % s != 0: p -= r ans[i].append(T) for i in range(p): ans.append(S) for i in range(N): print(*ans[i])