#include #include #include #include #include #include #include #include using namespace std; //#define __int64 long long #define long __int64 #define REP(i,a,b) for(int i=a;i> n; rep(i,n){ cin >> str; make(str); } cin >> m; rep(i,m){ cin >> str; make(str); } int cnt = 0; rep(i,alfaMax){ if(data[i].use){ if(data[i].next == -1){ cnt ++; } } } if(cnt != 1){ cout << "-1" << endl; }else{ string ans = ""; int now = search_first(); while(now != -1){ ans += (now + 'A'); now = data[now].next; } cout << ans << endl; } /* for(int i=0; i