#include <iostream>
#include <string>
using namespace std;
// Function to check if "SeriousOJ" is a subsequence of S
bool isSubsequence(const string& S, const string& target) {
int targetIndex = 0;
int targetLen = target.length();
for (char ch : S) {
if (ch == target[targetIndex]) {
targetIndex++;
if (targetIndex == targetLen) {
return true;
}
}
}
return false;
}
int main() {
int T;
cin >> T; // Number of test cases
string target = "SeriousOJ";
string result;
while (T--) {
int N;
cin >> N; // Length of the string S
string S;
cin >> S;
if (isSubsequence(S, target)) {
result += "YES\n";
} else {
result += "NO\n";
}
}
cout << result;
return 0;
}