#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef SUBLIME
freopen("inputf.in", "r", stdin);
freopen("outputf.out", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
int tt;
cin >> tt;
while (tt--) {
int n;
string s;
cin >> n >> s;
string t = "SeriousOJ";
int i = 0, j = 0;
while (i < n && j < (int)t.size()) {
if (s[i] == t[j]) {
i++;
j++;
}
else i++;
}
if (j == (int)t.size()) cout << "YES\n";
else cout << "NO\n";
}
return 0;
}