#include<stdio.h>
#include<string.h>
char s[100010];
char Word[1010];
void reverse(char* s) {
char* p = s - 1;
char* q = s + strlen(s);
while (++p < --q) {
char tmp = *p;
*p = *q;
*q = tmp;
}
}
int main() {
int i, j = 0, k = 0;
while ((s[j] = getchar()) != '\n') { j++; }
s[j] = '\0';
for (i = 0; i <= strlen(s); i++) {
if (s[i] == 32 || !s[i]) {
if (s[i] == 32 && s[i - 1] == 32) continue;
reverse(Word);
if (s[i] == 32) printf("%s\n", Word);
else printf("%s", Word);
memset(Word, 0, 1010);
k = 0;
}
else Word[k++] = s[i];
}
return 0;
}