n = int(input()) s = [input() for _ in range(n)] m = int(input()) t = [input() for _ in range(m)] ds = set(si[0] for si in s) dt = set(ti[0] for ti in t) if len(ds&dt)>1: print(-1) else: g = {} for si in s+t: for p,q in zip(si,si[1:]): g[p] = q ans = [] v = list(ds&dt)[0] while True: ans.append(v) if v not in g: break v = g[v] print("".join(ans))