var
  f: Text;
  G: array ['A'..'Z', 'A'..'Z'] of Boolean;
  P: set of 'A'..'Z';
  S: array [1..50] of String[20];
  i, j, k, N: Integer;
  ci, cj, ck: Char;
  b: Boolean;

procedure PP;
var
  ci, cj, ck: Char;
begin
  for ci := 'A' to 'Z' do
    if ci in P then begin
      Write(ci, ':');
      for cj := 'A' to 'Z' do
        if cj in P then if G[ci, cj] then Write(cj) else Write('.');
      Writeln;
    end;
end;

begin
//  Assign(f, 'in/put.txt'); Reset(f);
  Readln(N);
  for i := 1 to N do begin
    Readln(S[i]);
    for j := 1 to 20 do
      if S[i, j] <> '.' then Include(P, S[i, j]);
  end;
//  Close(f);
  for i := 1 to 20 do
    for j := 2 to N do
      for k := 1 to j - 1 do
        if (S[k, i] <> '.') and (S[j, i] <> '.') then
          G[S[k, i], S[j, i]] := true;
  for ck := 'A' to 'Z' do
    for ci := 'A' to 'Z' do
      for cj := 'A' to 'Z' do
        G[ci, cj] := G[ci, cj] or (G[ci, ck] and G[ck, cj]);
  for ci := 'A' to 'Z' do G[ci, ci] := false;
//  Assign(f, 'output.txt'); Rewrite(f);
  while P <> [] do begin
    {PP;}
    for ci := 'A' to 'Z' do begin
      if not (ci in P) then continue;
      b := false;
      for cj := 'A' to 'Z' do begin
        b := G[ci, cj];
        if b then break;
      end;
      if b then continue;
      for ck := 'A' to 'Z' do G[ck, ci] := false;
      Write(ci);
      Exclude(P, ci);
      break;
    end;
  end;
  Writeln();
//  Close(f);
end.
