/*
Author : MishkatIT
Created : Tuesday 10-12-2024 15:07:38
*/
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const int inf = 1e9;
const ll linf = 1e18;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc;
cin >> tc;
while (tc--) {
int n;
cin>> n;
string str;
cin >> str;
bool ok = true;
string x = "SeriousOJ";
int j = 0;
for (int i = 0; i < n && j < x.size(); i++) {
bool f = false;
while (i < n) {
if (str[i] == x[j]) {
j++;
f = true;
break;
}
i++;
}
if (!f) ok = false;
}
ok &= (j == x.size());
cout << (ok ? "YES" : "NO") << '\n';
}
return 0;
}