// Arup Guha
// 2/25/2020
// Solution to 2020 UCF HS Contest Problem: Silly Strings

import java.util.*;

public class silly {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int nC = stdin.nextInt();

		// Process each case.
        for (int loop=0; loop<nC; loop++) {

			// Read the input.
            int n = stdin.nextInt();
            char[] str = stdin.next().toCharArray();
			
			// First create frequency arrays for each of the 26 letters.
            int[][] freq = new int[26][n+1];
            for (int i=0; i<n; i++)
                freq[str[i]-'a'][i+1]=1;
			
			// Use the frequency arrays to go to cumulative frequency.
            for (int i=0; i<26; i++) {
                for (int j=1; j<=n; j++)
                    freq[i][j] += freq[i][j-1];
            }

			// Also store the totals here.
            int[] total = new int[26];
            for (int i=0; i<26; i++) total[i] = freq[i][n];

			// Answer for even case.
            int res = 0;
			
			// All the real work is in odd.
            if (n%2 == 1) {

				// Try removing each character.
                for (int i=0; i<n; i++) {

                    int limit = n/2;
					
					// If char is from the first half, update limit.
					// Adjust both necessary frequencies.
                    if (i <= n/2) {
                        limit = n/2+1;
                        freq[str[i]-'a'][limit]--;
                    }
                    total[str[i]-'a']--;

					// In order for this character to work, the frequencies of all 26 characters must be
					// exactly twice for the whole string as the first "half".
                    boolean ok = true;
                    for (int j=0; j<26; j++)
                        if (freq[j][limit]*2 != total[j])
                            ok = false;

					// Count it!
                    if (ok) res++;

					// Fix both arrays to be back to where they were for next iteration.
                    total[str[i]-'a']++;
                    if (i<= n/2) {
                        freq[str[i]-'a'][limit]++;
                    }
                }
            }

			// Ta da!
            System.out.println(res);
        }
    }
}