#include <iostream>
#include <algorithm>
using namespace std;
string s[1003];
bool is_digit(string &str){
for(int i=0;i<str.size();i++) if(str[i]>'9'||str[i]<'0') return false;
return true;
}
int tot;
int main(){
while(cin>>s[++tot]){
if(is_digit(s[tot])) reverse(s[tot].begin(),s[tot].end());
else if(s[tot][0]<='Z')
for(int i=0;i<s[tot].size();i++) s[tot][i]+=32;
else
for(int i=0;i<s[tot].size();i++) s[tot][i]-=32;
}
for(int i=tot;i>=1;i--) cout<<s[i]<<' ';
return 0;
}