def solve(): N = int(input()) S = f"*{input().strip()}" Mod = 998244353 inv = [0] * (N + 2); inv[1] = 1 for x in range(2, N + 2): q, r = divmod(Mod, x) inv[x] = (- q * inv[r]) % Mod total = 0 g = 0 for i in range(1, N + 1): if i < N and S[i] == 'G': g += 1 continue a = (g + 1) * (g + 2) % Mod total += a * inv[i + 1]; total %= Mod g = 0 coef = (N + 1) * inv[2] % Mod return coef * total % Mod #================================================== import sys input = sys.stdin.readline write = sys.stdout.write T = int(input()) write("\n".join(map(str, [solve() for t in range(T)])))