#include <stdio.h>
#include <stdbool.h>
 
#define FOR(i, n) for (int i=0; i<n; i++)
int lg[(1 << 15) + 1]; // I'm too lazy to do this properly
 
void run(void) {
	int n;
	char aa[17], bb[17];
	int a[16], b[16];
	scanf("%d %s %s", &n, aa, bb);
	FOR(i, n)
		a[i] = aa[i] - 'a', b[i] = bb[i] - 'a';
	
	int mask = 0; // current bitmask
	int cha[26], chb[26]; // count # of each character for the current mask
	FOR(i, 26)
		cha[i] = chb[i] = 0;
	 
	int cnta = 0, cntb = 0; // count # of distinct characters
#define ADD(chx, cntx, c) (cntx += !(chx[c]++))
#define DEL(chx, cntx, c) (cntx -= !(--chx[c]))
	 
	FOR(i, n)
		ADD(cha, cnta, a[i]), ADD(chb, cntb, b[i]);
	 
	int res = (cnta < cntb) ? cntb : cnta;
	 
	for (int i=1; i < 1<<n; i++) {
		int lbit = i & (-i); // the least significant bit
		int pos = lg[lbit];
		mask ^= lbit;
		if (mask & lbit) {// we have just switched it on, i. e. we swap a[i] and b[i]
			ADD(cha, cnta, b[pos]), DEL(cha, cnta, a[pos]);
			ADD(chb, cntb, a[pos]), DEL(chb, cntb, b[pos]);
		} else {
			ADD(cha, cnta, a[pos]), DEL(cha, cnta, b[pos]);
			ADD(chb, cntb, b[pos]), DEL(chb, cntb, a[pos]);
		}
	 
		int max = (cnta > cntb) ? cnta : cntb;
		res = (res < max) ? res : max;
	}
 
	printf("%d\n", res);
}
 
int main(void) {
	FOR(i, 16)
		lg[1 << i] = i;
	int t;
	scanf("%d", &t);
	while (t--)
		run();
	return 0;
}