#include <bits/stdc++.h>
using namespace std;
string operation1(string s){
return s;
}
string operation2(string s){
return s;
}
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+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJpbmcgb3BlcmF0aW9uMShzdHJpbmcgcyl7CglyZXR1cm4gczsKfQoKc3RyaW5nIG9wZXJhdGlvbjIoc3RyaW5nIHMpewoJcmV0dXJuIHM7Cn0KCgppbnQgbWFpbigpIHsKCWludCB0OyBjaW4gPj4gdDsKCXdoaWxlKHQtLSl7CgkJaW50IG47IGNpbiA+PiBuOwoJCXN0cmluZyBzOyBjaW4gPj4gczsgaW50IGxlbiA9IHMubGVuZ3RoKCk7CgkJc3RyaW5nIGZpbmFsOwoJCWlmKHNbMF0tJ2EnIDw9IHNbbGVuLTFdLSdhJykKCQkJZmluYWwgPSBvcGVyYXRpb24xKHMpOwoJCWVsc2UKCQkJZmluYWwgPSBvcGVyYXRpb24yKHMpOwoJCWNvdXQgPDwgZmluYWwgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9