#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define yes cout << "YES" << "\n";
#define no cout << "NO" << "\n";
#define fri(a,b) for(ll i = a; i<b; i++)
#define frj(a,b) for(ll j = a; j <b; j++)
#define frk(a,b) for(ll k = a; k <b; k++)
#define rfri(a,b) for(ll i = a; i>=b; i--)
using namespace std;
int main()
{
ios_base:: sync_with_stdio(false);
cin.tie(NULL);
ll T = 1;
cin >> T;
while(T--)
{
ll n;
cin >> n;
string s;
cin >> s;
string s1 = "SeriousOJ";
ll j = 0;
fri(0,n)
{
if(s[i] == s1[j])
{
j++;
}
}
if(j==9) yes
else no
}
}