#include <bits/stdc++.h>
using namespace std;
string operation1(string s){
return s;
}
string operation2(string s){
string temp = s;
sort(s.rbegin(), s.rend());
string temp2 = s + temp;
return temp2;
}
int main() {
int t; cin >> t;
while(t--){
int n; cin >> n;
string s; cin >> s; int len = s.length();
string final;
if(s[0]-'a' <= s[len-1]-'a')
final = operation1(s);
else
final = operation2(s);
cout << final << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJpbmcgb3BlcmF0aW9uMShzdHJpbmcgcyl7CglyZXR1cm4gczsKfQoKc3RyaW5nIG9wZXJhdGlvbjIoc3RyaW5nIHMpewoJc3RyaW5nIHRlbXAgPSBzOwoJc29ydChzLnJiZWdpbigpLCBzLnJlbmQoKSk7CglzdHJpbmcgdGVtcDIgPSBzICsgdGVtcDsKCXJldHVybiB0ZW1wMjsKfQoKCmludCBtYWluKCkgewoJaW50IHQ7IGNpbiA+PiB0OwoJd2hpbGUodC0tKXsKCQlpbnQgbjsgY2luID4+IG47CgkJc3RyaW5nIHM7IGNpbiA+PiBzOyBpbnQgbGVuID0gcy5sZW5ndGgoKTsKCQlzdHJpbmcgZmluYWw7CgkJaWYoc1swXS0nYScgPD0gc1tsZW4tMV0tJ2EnKQoJCQlmaW5hbCA9IG9wZXJhdGlvbjEocyk7CgkJZWxzZQoJCQlmaW5hbCA9IG9wZXJhdGlvbjIocyk7CgkJY291dCA8PCBmaW5hbCA8PCBlbmRsOwoJfQoJcmV0dXJuIDA7Cn0=