#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(a) cout<< #a << " : " << a << endl;
#define bug2(a, b) cout << #a << " : " << a << " " << #b << " : " << b << endl;
string f = "SeriousOJ";
void solve(int cs){
int n;
string s;
cin >> n >> s;
int idx = 0;
for(auto u : s){
if(u == f[idx]) idx++;
if(idx == f.size()) break;
}
if(idx == f.size()) cout << "YES\n";
else cout << "NO\n";
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
cout.tie(0);
int tc = 1;
cin >> tc;
for(int cs = 1; cs <= tc; cs++){
solve(cs);
}
}