#include<bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<"\n";
#define no cout<<"NO"<<"\n";
#define forn for(int i=0;i<n;i++);
#define acin for(int i=0;i<n;i++)cin>>arr[i];
#define v vector<int>arr(n);
//#define int long long
void solve()
{
int n;
cin>>n;
string s;
cin>>s;
string s1="SeriousOJ";
int cnt=0;
for (int i = 0, j = 0; i < n; i++)
{
if (s[i] == s1[j])
{
j++;
cnt++;
}
}
if (s1.size() == cnt)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int main()
{
int t;
cin>>t;
while (t--)
{
solve();
}
}