public static void main(String[] args) throws Throwable{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		mAdy=new boolean[30][30];
		String ant = null;
		TreeSet<Integer> letras = new TreeSet<Integer>();
		for (String line; (line = in.readLine())!=null; ) {
			if(line.charAt(0)=='#')break;
			if(ant == null){
				ant = line;
			}else{
				int min =Math.min(ant.length(), line.length());
				for(int i=0;i<min;++i){
					int f = (int)(ant.charAt(i)-'A');
					int c = (int)(line.charAt(i)-'A') ;
					letras.add(f);
					letras.add(c);
					if(f!=c){
						mAdy[f][c]=true;
						break;
					}
				}
				ant=line;
			}
		}
		int[][] lAdy = tolAdy(mAdy);
		int[] orden = topologicalSort(lAdy);
		for(int i=0;i<orden.length;++i){
			if(letras.contains(orden[i])){
				System.out.print((char)(orden[i]+'A'));
			}
		}
		System.out.println();
	}