using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; static List[] li; static void Main(){ Sc sc=new Sc(); int n=26,g=0; li=new List[n]; var h=new int[n]; for(int i=0;i();} int m=sc.I; for(int i=0;i0){ int p=tp[i],z=1; while(li[p].Count>0){ p=li[p][0]; z++; } p=tp[i]; if(z==g){ Console.Write((char)(p+'A')); while(li[p].Count>0){ p=li[p][0]; Console.Write((char)(p+'A')); } Console.WriteLine(); } else {Console.WriteLine(-1);} return; } } Console.WriteLine("{0}",-1); } } public class Tp{ private bool[] b; private int k; private List[] li; public int[] ar; public Tp(List[] li,int n){ this.li=li; b=new bool[n]; ar=new int[n]; k=n-1; for(int i=n-1;i>=0;i--){if(!b[i]){Fu(i);}} } public int this[int i]{get{return ar[i];}} private void Fu(int a){ b[a]=true; for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i