program pil_10_17_b(input,output);
const
  n = 30;
  k = 8;
type
  str = packed array [1..k] of char;
var
  mas : array [1..n] of str;
  last, cur, template : str;
  c, FirstChar : char;
  i, j, All : integer;
  flag, tmp : boolean;
begin
  for i:=1 to k do
    template[i] := ' ';
  {input data}
  i := 1;
  repeat
    read(c);
    j := 1;
    mas[i] := template;
    while (c<>'.')and(c<>',') do begin
      mas[i,j] := c;
      j := j+1;
      read (c);
    end;
    i := i+1;
  until c='.';
  All := i-1;
  last := mas[All];
  for i:=1 to All-1 do begin
    cur := mas[i];
    if cur<>last then begin
      FirstChar := cur[1];
      j := 2;
      flag := false;
      tmp := true;
      while (j<=k)and(not flag)and tmp do begin
        flag := cur[j]=FirstChar;
        tmp := cur[j]=' ';
        j := j+1;
      end;
      if flag then WriteLn(cur);
    end;
  end;
end.
