#include <stdio.h>
#include <string.h>
#include <ctype.h>
void reversWord(vhar* start, char* end){
    while(start < end){
        char temp = *start;
        *start = *end;
        *end = temp;
        start++;
        end--;
    }
}
int main(){
    char s[101];
    printf(" ");
    fgets(s, sizeof(s), stdin);
    s[strcspn(s, "\n")] = 0;
    
    for(int i = 0; s[i] != '\0'; i++){
        if(!isalpha(s[i]) && s[i] != ' '){
            printf("Invalid input\n");
            return 0;
        }
    }
    char* word_start = s;
    char* current = s;
    while(*current != '\0'){
        if(*current == ' '){
            reversWord(word_start, current - 1);
            word_start = current + 1;
            
        }
        current++;
    }
    reversWord(word_start, current - 1);
    printf("%s\n", s);
    return 0;
}