program lab99;
uses crt;
procedure ppp;
var
f: Text;
i: integer;
b: boolean;
s: string;
c: char;
begin
assign(f, 'input.txt');
reset(f);
s := '';
while not eof(f) do
begin
read(f, c);
if (c = '.') or (c = '?') or (c = '!') then
begin
i := 1;
b := false;
while (i <= Length(s)) and (not b) do
begin
b := (s[i] in ['a'..'z', 'A'..'Z']) and ((i = 1) or (s[i-1] = ' ')) and ((i = Length(s)) or (s[i+1] = ' '));
inc(i);
end;
if b then writeln(s, c);
s := '';
end
else s := s + c;
end;
close(f);
end;
begin
ppp;
readln;
end.