#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define PI acos(-1.0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define rev_str(str) reverse(str.begin(),str.end());
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i =a ;i<b;i++)
#define per(i,b,a) for(ll i=b;i>=a;i--)
#define all(a) (a.begin(),a.end())
#define srt(a) sort(all(a))
#define rsrt(a) sort(a.rbegin(),a.rend())
bool sortByValue(const pair<int,int>& a,const pair<int,int>& b){
return a.second > b.second;
}
const ll N=10e5+5;
ll gcd(ll a,ll b){
return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a,ll b){
return (a / gcd(a, b)) * b;
}
void solve(){
int n;
cin >> n;
string s;
cin >> s;
string t = "SeriousOJ";
int j = 0;
for (int i = 0; i < n; i++){
if (s[i] == t[j]){
j++;
}
}
cout << (j == t.size() ? "YES" : "NO") << endl;
}
int main(){
fast;
ll t=1;cin>>t;
while(t--){
solve();
}
return 0;
}