#http://bigocoder.com/courses/ONLINE_ORANGE/ONLINE_ORANGE_L01/ORANGE_L01P03/statement from collections import defaultdict import string def dfs (u, graph, visited, result): if visited[u] == 1: return False visited[u] = 1 if u in graph.keys(): for v in graph[u]: if v in visited: if visited[v] != 1: dfs(v, graph, visited, result) else: result.append(v) visited[u] = 2 result.append(u) def topologicalSort(graph, result): for element in graph.keys(): if visited[element] == 0: if not dfs(element, graph, visited, result): return False result.reverse() return True def compareTwoString(str1, str2): i,j = 0,0 while i < len(str1) and j < len(str2): if str1[i] != str2[j]: graph[str1[i]].append(str2[j]) break i+=1 j+=1 number_of_names = int(input()) list_names, result = [], [] graph, visited = defaultdict(list), {} for i in range(number_of_names): list_names.append(str(input())) for i in range(len(list_names)-1): str1, str2 = list_names[i], list_names[i+1] if len(str2) < len(str1) and str2.startswith(str1): print("Impossible") break else: compareTwoString(str1, str2) for element in graph.keys(): visited[element] = 0 print(visited) isThereNoLoop = topologicalSort(graph, result) if isThereNoLoop: final_result = ''.join(result) for element in string.ascii_lowercase: if element not in final_result: final_result += element print(final_result) else: print("Impossible")