http://acm.hdu.edu.cn/showproblem.php?pid=2573
//字符串
#include <iostream>
#include <string>
using namespace std;
int main()
{
int t, k;
bool Caps;
string str, res;
cin >> t;
while (t--) {
cin >> k;
Caps = false;
res.clear();
while (k--) {
cin >> str;
if (str == "Caps") Caps = !Caps;
if (str.find("Shift") != string::npos) {
cin >> str;
Caps = !Caps;
if (Caps == false) res+=(tolower(str[0]));
else res+=(toupper(str[0]));
Caps = !Caps;
continue;
}
if (str.length() == 1) {
if (Caps == false) res+=(tolower(str[0]));
else res+=(toupper(str[0]));
}
}
cout << res << endl;
}
return 0;
}