#include #include #include using namespace std ; bool edge[30][30] ; int pred[30], succ[30] ; int main() { char lastlet ; int nwords ; cin >> lastlet >> nwords ; string prev, w ; bool inconsistent = false ; int nlet = lastlet - 'a' + 1 ; for (int i=0; i> w ; int d = 0 ; while (d < prev.size() && d < w.size() && prev[d] == w[d]) d++ ; if (d >= prev.size()) continue ; if (d >= w.size()) { inconsistent = 1 ; continue ; } if (edge[prev[d]-'a'][w[d]-'a'] == 0) { edge[prev[d]-'a'][w[d]-'a'] = 1 ; pred[w[d]-'a']++ ; succ[prev[d]-'a']++ ; } } string res ; bool insuff = false ; for (int i=0; i