#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(a) cout << #a << " : " << a << endl;
void solve(){
int n; cin >> n;
string s; cin >> s;
string tar = "SeriousOJ";
int idx = 0;
int cnt = 0;
for(int i = 0; i < n; i++){
if ( idx == 9 ) break;
if (s[i] == tar[idx]){
idx++;
cnt++;
}
}
cout << (cnt == tar.size() ? "YES" : "NO") << '\n';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tc = 1, cs = 0;
cin >> tc;
while(tc--){
//cout << "Case # " << ++cs << ": " ;
solve();
}
}