// Problem: E - (∀x∀)
// Contest: AtCoder - AtCoder Beginner Contest 242
// URL: https://atcoder.jp/contests/abc242/tasks/abc242_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 2022-03-05 23:18:57
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;

#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define pii pair<int, int>
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pair

//const ll mod = 1e9 + 7;
const ll mod = 998244353;

inline ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a%mod;
a = a * a %mod;
b >>= 1;
}
return ans;
}
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {
return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {
return (a + b) %mod;
}
inline ll inv (ll a) {
return qmi(a, mod - 2);
}

const int N = 1e6 + 10;
ll dp[N][2];

ll cal (ll a, ll b) {
return ((a + b) % mod + mod) %mod;
}
void solve() {
int n;
cin >> n;
string s;
cin >> s;
ll ans = 0, p = 1;
for (int i = 0; i < (n + 1) / 2; i ++) {
ans = (ans * 26 % mod + s[i] - 'A') %mod;
}
string a = s.substr(0, (n + 1)/ 2);
string b = a;

reverse(all(b));
if (n % 2) b.erase(b.begin());

if ((a + b) <= s) ans = cal(ans, 1);
printf("%lld\n", ans);
}
int main () {
// ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
int t;
t =1;
cin >> t;
while (t --) solve();
return 0;
}


// Problem: E - (∀x∀)
// Contest: AtCoder - AtCoder Beginner Contest 242
// URL: https://atcoder.jp/contests/abc242/tasks/abc242_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 2022-03-05 23:18:57
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;

#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define pii pair<int, int>
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pair

//const ll mod = 1e9 + 7;
const ll mod = 998244353;

inline ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a%mod;
a = a * a %mod;
b >>= 1;
}
return ans;
}
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {
return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {
return (a + b) %mod;
}
inline ll inv (ll a) {
return qmi(a, mod - 2);
}

const int N = 1e6 + 10;
ll dp[N][2];

int cal (int a, int b) {
return ((a + b) % mod + mod) %mod;
}
void solve() {
int n;
n = read();
int newn = n;
string s;
cin >> s;
string a =s, b = s, tt = s;
s = " " + s;

for (int i = 0; i <= n; i ++)
dp[i][0]= dp[i][1] = 0;
dp[0][0] = 1;
ll ans = 0;
if (n % 2) n ++;
n /= 2;
for (int i = 1; i <= n; i ++) {

dp[i][1] = cal(dp[i][1], dp[i - 1][1] * 26 %mod);
dp[i][0] = dp[i - 1][0];
dp[i][1] = cal(dp[i - 1][0] * (s[i] - 'A') % mod, dp[i][1]);
}
ans = dp[n][1];
a = a.substr(0, n);
b = a;
reverse(all(a));
if (newn % 2)
a.erase(a.begin());
if ((b + a) <= tt) ans = cal(ans, 1);
printf("%lld\n", ans);
}
int main () {
// ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
int t;
t =1;
cin >> t;
while (t --) solve();
return 0;
}


我首先是通过研究一些特殊的例子,然后找到思路,dp做的,但是有些特殊情况没有处理好,比如相等的时候是否能够加上,6511->6556这种情况是不能加上的。这种情况没有处理好。但是dp还是能做的。 但是我们也能够找到规律,6566有65种,这是10进制的,题目是26进制的。我们首先算出所有小于的解。然后再判断等于的是否符合 问题结构: 有约束条件