#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using o_set = tree<T, null_type, std::less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
void solve() {
int n;
cin >> n;
string s, t = "SeriousOJ";
cin >> s;
int ind = 0, m = (int) t.size();
for (int i = 0; i < n; i++) {
if(ind == m) break;
if(s[i] == t[ind]) ind++;
}
if(ind == m) cout << "YES\n";
else cout << "NO\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin>>t;
for(int tc = 1; tc <= t; tc++) {
// cout<<"Case "<<tc<<":";
solve();
}
}