#include<bits/stdc++.h>
using namespace std;
void cver(char*str)
{
if(islower(str[0]))str[0]=toupper(str[0]);
for(int i=1;i<strlen(str);i++)
{
if(isupper(str[i]))str[i]=tolower(str[i]);
}
}
char s[30];
int main()
{
int n;
cin>>n;
while(n--)
{
cin.getline(s,30);
cver(s);
for(int i=0;i<strlen(s);i++)
{
cout<<s[i];
}
cout<<endl;
}
return 0;
}