#include <bits/stdc++.h>
using namespace std;
const int N = 100000, C = 20;
int n;
char s[N + 9], t[N + 9];
void into() { scanf("%d%s%s", &n, s + 1, t + 1); }
int to[N + 9], e[C + 9][C + 9];
void Get_graph() {
  for (int i = 0; i < C; ++i) {
    to[i] = 0;
    for (int j = 0; j < C; ++j) e[i][j] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    int x = s[i] - 'a', y = t[i] - 'a';
    to[x] |= 1 << y;
    e[x][y] = e[y][x] = 1;
  }
}
int vis[C + 9], cnt;
void Dfs_vis(int k) {
  vis[k] = 1;
  for (int i = 0; i < C; ++i)
    if (e[k][i] && !vis[i]) Dfs_vis(i);
}
void Get_cnt() {
  cnt = 0;
  for (int i = 0; i < C; ++i) vis[i] = 0;
  for (int i = 0; i < C; ++i)
    if (!vis[i]) ++cnt, Dfs_vis(i);
}
int dp[(1 << C) + 9], ans;
void Get_dp() {
  ans = 0;
  for (int s = 0; s < 1 << C; ++s) dp[s] = 0;
  dp[0] = 1;
  for (int s = 0; s < 1 << C; ++s) {
    if (!dp[s]) continue;
    int cnt = 0;
    for (int i = 0; i < C; ++i) {
      cnt += s >> i & 1;
      if (s >> i & 1) continue;
      if (!(to[i] & s)) dp[s | 1 << i] = 1;
    }
    ans = max(ans, cnt);
  }
}
void work() {
  Get_graph();
  Get_cnt();
  Get_dp();
}
void outo() { printf("%d\n", C * 2 - cnt - ans); }
int main() {
  int T;
  scanf("%d", &T);
  for (; T--;) {
    into();
    work();
    outo();
  }
  return 0;
}
