word_list = [[],[]] initial = [] head_w = [] word_length = 0 for i in range(int(input())): word = input() word_list[0].append(word) initial.append(word[0]) word_length += len(word) for i in range(int(input())): word = input() word_list[1].append(word) if word[0] in initial: head_w.append(word[0]) if len(head_w)!=1: print(-1) else: ans = head_w[0] choise_flag = 0 while len(ans)!=word_length: tgt = ans[-1] for i,w in enumerate(word_list[choise_flag]): if tgt in w: ans += w[w.index(tgt)+1:] word_list[choise_flag].pop(i) choise_flag = (choise_flag+1)%2 print(ans)