#include
#include
#include
#include
using namespace std;
int main()
{
short T;
cin >> T;
short i = 0;
string str[100];
cin.ignore();
while(i++ < T)
getline(cin, str[i]);
string tmp;
vector <string> v;
i = 0;
while(i++ < T)
{
v.clear();
stringstream ss(str[i]);
while(ss >> tmp)
v.push_back(tmp);
for(auto &w : v)
{
if(w.size() == 1)
{
LOOP:
cout << (char)toupper(w[0]);
for(unsigned short j=1; j<w.size(); j++)
cout << (char)tolower(w[j]);
cout << endl;
}
else
{
if(&w != &v.back())
cout << (char)toupper(w[0]) << "." << ends;
else
goto LOOP;
}
}
}
return 0;
}