# -*- coding: utf-8 -*- def solve(input): chain = {} s = set([]) for w in input: if w.isdigit() : continue for i in xrange(len(w)) : s.add(w[i]) if i + 1 < len(w) : chain[w[i]] = w[i + 1] if len(s) == 1 : return s.pop() if len(s) - 1 > len(chain) : return "-1" k = set(chain.keys()) v = set(chain.values()) first = ((k ^ v) & k).pop() end = ((k ^ v) & v).pop() i = first r = first while i != end : r += chain[i] i = chain[i] return r pass if __name__ == "__main__": input = [] ln = int(raw_input()) input.append(str(ln)) for l in xrange(ln): input.append(raw_input()) ln = int(raw_input()) input.append(str(ln)) for l in xrange(ln): input.append(raw_input()) print solve(input)