rt
#include <bits/stdc++.h>
#define N 1001
using namespace std;
string str[N];
int cnt;
signed main()
{
while (cin >> str[++cnt])
{
if ('0' <= str[cnt][0] && str[cnt][0] <= '9')
{
for (int i = 0; i < str[cnt].size() / 2; i++)
{
swap(str[cnt][i], str[cnt][i + str[cnt].size() - 1]);
}
}
else
{
for (int i = 0; i < str[cnt].size(); i++)
{
if ('A' <= str[cnt][i] && str[cnt][i] <= 'Z')
{
str[cnt][i] += 32;
}
else
{
str[cnt][i] -= 32;
}
}
}
}
for (int i = cnt - 1; i > 0; i--)
{
cout << str[i] << " ";
}
return 0;
}