import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;

public class CF1385D {
	public static void main(String[] args) throws Exception {
		new CF1385D().run();
	}

	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		///
		int t = f.nextInt();
		while(t-->0) {
			int n = f.nextInt();
			String s = f.nextLine();
			
			String firstHalf = s.substring(0,s.length()/2);
			String secHalf = s.substring(s.length()/2);
			
			out.println(firstHalf + " " + secHalf);
			
			
			System.out.println(check(firstHalf, secHalf, n, 'a'));
			
		}
		///
		out.flush();
	}
	
	public int check(String first, String sec, int n, char c) {
		if(n == 0 || first.length() != sec.length()) return 0;
		
		int firstC = 0, fi = 0, secC = 0, se = 0;
		for(int i = 0; i < n/2; i++) {
			if(first.charAt(i) == c) firstC++;
			if(sec.charAt(i) == c) secC++;	
		}
		
		System.out.println(n + " " + first + " " + sec);
		
		fi = check(first.substring(0,first.length()/2), first.substring(first.length()/2), n/2, (char)(c+1));
		se = check(sec.substring(0,sec.length()/2), sec.substring(sec.length()/2), n/2, (char)(c+1));
		
		if(firstC == n/2) return firstC;
		else if(secC == n/2) return secC;
		else if(se + firstC > fi + secC) return se + firstC;
		else return fi + secC;

		
	}

	///
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}