using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<char, List<char>>();
        var n = int.Parse(Console.ReadLine().Trim());
        setDic(d, n);
        n = int.Parse(Console.ReadLine().Trim());
        setDic(d, n);
        var res = getAns(d);
        Console.WriteLine(res);
    }
    public static string getAns (Dictionary<char,List<char>> d)
    {
        var c = d.Count(x => x.Value.Count() == 0);
        if (c >= 2) return "-1";
        var hs = new HashSet<char>();
        foreach (var x in d) hs.Add(x.Key);
        foreach (var x in d)
            foreach (var y in x.Value)
                hs.Remove(y);
        var nextchar = hs.First();
        var res = nextchar.ToString();
        while (true)
        {
            if (d[nextchar].Count() == 0) break;
            res += d[nextchar][0];
            nextchar = d[nextchar][0];
        }
        return res;
    }
    public static void setDic (Dictionary<char,List<char>> d,int n)
    {
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            var sL = s.Length;
            for (int j = 0; j < s.Length-1; j++)
                if (d.ContainsKey(s[j]))
                {
                    if (d[s[j]].Count() == 0) d[s[j]].Add(s[j + 1]);
                }
                else d[s[j]] = new List<char>() { s[j + 1] };
            if (!d.ContainsKey(s[sL - 1]))
                d[s[sL - 1]] = new List<char>();
        }
    }
}