using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var s = SList(n); var dic = new Dictionary>(); for (var i = 0; i < n; ++i) { var counts = new int[26]; foreach (var c in s[i]) ++counts[c - 'a']; for (var c = 0; c < 26; ++c) { ++counts[c]; var data = new Data(counts); if (dic.ContainsKey(data)) dic[data].Add(i); else dic[data] = new List{ i }; } } foreach (var kv in dic) { if (kv.Value.Count == 1) { var ans = new List(); for (var c = 0; c < kv.Key.List.Length; ++c) for (var i = 0; i < kv.Key.List[c]; ++i) ans.Add((char)(c + 'a')); WriteLine(string.Concat(ans)); return; } } WriteLine(-1); } class Data { public int Key; public int[] List; public Data(int[] list) { List = (int[]) list.Clone(); var k = 0L; foreach (var li in list) k = (k * 11 + li) % 1_000_000_007; Key = (int)k; } public override bool Equals(object obj) { var b = obj as Data; if (Key != b.Key) return false; for (var i = 0; i < List.Length; ++i) if (List[i] != b.List[i]) return false; return true; } public override int GetHashCode() { return Key; } } }