#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% N = int(readline()) A = [readline().decode().rstrip() for _ in range(N)] M = int(readline()) B = [readline().decode().rstrip() for _ in range(M)] # %% E = dict() V = set() for word in A + B: V |= set(word) for x, y in zip(word, word[1:]): E[x] = y # %% def solve(V, E): start = V - set(E.values()) if len(start) != 1: return None x = start.pop() chain = [x] while True: if x not in E: break x = E[x] chain.append(x) if len(chain) < len(V): return None return ''.join(chain) # %% S = solve(V,E) if not S: print(-1) else: print(S) # %%