#include<iostream>
#include<cctype>
#include<string>
#include<algorithm>
using namespace std;
string str;
void reve(int, int);
int main(){
while(getline(cin, str)){//字符串可能有空格,所以使用getline
int i = 0, j = 0;
int index = 0;
bool isal = false;
int len = str.length();
while(index < len){//当下标美越界
if(isalpha(str[index])){//如果是字母
if(!isal){//如果前一个不是字母
i = index;
isal = true;
}else{
j = index;
}
}else{//如果不是字母
if(isal){//如果前一个是字母
j = index - 1;
reve(i, j);
isal = false;
}
}
index++;
}
if(isal && i <= j){//如果还有没有操作完的,再进行一次
reve(i, j);
}
cout << str << endl;
}
return 0;
}
void reve(int i, int j){//单词反转函数,传入单词的始末下标
string substr = str.substr(i, j - i + 1);
reverse(substr.begin(), substr.end());
str = str.substr(0, i) + substr + str.substr(j + 1);
}
//presented by 大吉大利,今晚AC