#include <bits/stdc++.h>
using namespace std;
#define int long long
#define enl "\n"
#define all(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 19;
string x = "seriousOJ";
void solve() {
int n;
cin >> n;
string s1, s2 = "SeriousOJ";
cin >> s1;
int m = s2.size();
int dp[n + 1][m + 1];
for(int i = 0; i <= n; i++) dp[i][0] = 0;
for(int i = 0; i <= m; i++) dp[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s1[i - 1] == s2[j - 1]) {
dp[i][j] = dp[i - 1][j - 1] + 1;
} else {
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
}
}
}
string lcs = "";
int i = n, j = m;
while (i > 0 && j > 0) {
//cout << i << ' ' << j << endl;
if (s1[i - 1] == s2[j - 1]) {
lcs = s1[i - 1] + lcs;
i--, j--;
}
else if (dp[i - 1][j] > dp[i][j - 1]) i--;
else j--;
}
if(lcs == s2) cout << "YES" << endl;
else cout << "NO" << endl;
}
signed main()
{
FAST
int T = 1;
cin >> T;
for(int tt = 1; tt <= T; tt++) {
//cout << "Case " << tt << ": ";
solve();
}
return 0;
}