#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define srt(v) sort(v.begin(), v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define pb push_back
void solve(){
int n; cin >> n;
string s; cin >> s;
set<string>st;
bool chk=true;
string s2= "SeriousOJ";
int j=0;
int cnt=0;
for(int i=0; i<s.size(); i++){
if(s[i]==s2[j]){
j++;
cnt++;
}
}
if(cnt==9){
cout << "YES\n";
}else{
cout << "NO\n";
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while(t--){
solve();
}
}