# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def read(): N = II() A = [] for __ in range(N): A.append(str(input())) M = II() B = [] for __ in range(M): B.append(str(input())) return (N, A, M, B) def solve(N, A, M, B): dict_next = collections.defaultdict(None) all_len = 0 for a in A: all_len += len(a) for char_a in a: dict_next[char_a] = None def update_dict(str_list): for str in str_list: for i in range(len(str) - 1): dict_next[str[i]] = str[i + 1] update_dict(A) update_dict(B) count_none = 0 for value in dict_next.values(): if value is None: count_none += 1 ans = "" if count_none != 1: ans = -1 else: l_ans = [] now_char = "" for key, value in dict_next.items(): if value is None: now_char = key l_ans.append(now_char) while len(l_ans) != all_len: for key, value in dict_next.items(): if value is now_char: l_ans.append(key) now_char = key break else: l_ans.reverse() ans = "".join(l_ans) return ans def main(): params = read() print(solve(*params)) if __name__ == "__main__": main()