Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understanding). You can make hacks in these problems independently.

Koa the Koala has two strings A and B of the same length n (|A|=|B|=n) consisting of the first 20 lowercase English alphabet letters (ie. from a to t).

In one move Koa:

  1. selects some subset of positions p_1, p_2, …, p_k (k ≥ 1; 1 ≤ p_i ≤ n; p_i ≠ p_j if i ≠ j) of A such that A_{p_1} = A_{p_2} = … = A_{p_k} = x (ie. all letters on this positions are equal to some letter x).

  2. selects a letter y (from the first 20 lowercase letters in English alphabet) such that y>x (ie. letter y is strictly greater alphabetically than x).

  3. sets each letter in positions p_1, p_2, …, p_k to letter y. More formally: for each i (1 ≤ i ≤ k) Koa sets A_{p_i} = y.

Note that you can only modify letters in string A.




Koa wants to know the smallest number of moves she has to do to make strings equal to each other (A = B) or to determine that there is no way to make them equal. Help her!

Input

Each test contains multiple test cases. The first line contains t (1 ≤ t ≤ 10) — the number of test cases. Description of the test cases follows.

The first line of each test case contains one integer n (1 ≤ n ≤ 10^5) — the length of strings A and B.

The second line of each test case contains string A (|A|=n).

The third line of each test case contains string B (|B|=n).

Both strings consists of the first 20 lowercase English alphabet letters (ie. from a to t).

It is guaranteed that the sum of n over all test cases does not exceed 10^5.

Output

For each test case:

Print on a single line the smallest number of moves she has to do to make strings equal to each other (A = B) or -1 if there is no way to make them equal.

Example

Input


5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda


Output


2
-1
3
2
-1

Note

  * In the 1-st test case Koa: 
    1. selects positions 1 and 2 and sets A_1 = A_2 =  b (\color{red}{aa}b → \color{blue}{bb}b). 
    2. selects positions 2 and 3 and sets A_2 = A_3 =  c (b\color{red}{bb} → b\color{blue}{cc}). 

  * In the 2-nd test case Koa has no way to make string A equal B.

  * In the 3-rd test case Koa: 
    1. selects position 1 and sets A_1 =  t (\color{red}{a}bc → \color{blue}{t}bc). 
    2. selects position 2 and sets A_2 =  s (t\color{red}{b}c → t\color{blue}{s}c). 
    3. selects position 3 and sets A_3 =  r (ts\color{red}{c} → ts\color{blue}{r}). 
import java.util.*;
import java.io.*;

public class Codeforces_1384_C {
	static FastReader sc;
	static PrintWriter pw;

	public static void main(String[] args) throws FileNotFoundException {
		boolean submit = true;
		sc = new FastReader(submit);
		pw = new PrintWriter(System.out);

		int T = sc.nextInt();
		for (int t = 0; t < T; t++) {

			solve();
			pw.flush();
		}

		pw.close();

	}

	static void solve() {
		// Solution
		int n = _int();

		String A = _string();
		String B = _string();

		for (int i = 0; i < n; i++) {
			if (A.charAt(i) > B.charAt(i)) {
				Println(-1);
				return;
			}
		}

		char[] Ac = A.toCharArray();
		char[] Bc = B.toCharArray();

		int count = 0;

		for (char curr = 'a'; curr <= 'u'; curr++) {
			char minchar = 'z';
			for (int i = 0; i < n; i++) {
				if (Ac[i] == curr) {
					if (Bc[i] != curr) {
						if (Bc[i] < minchar) {
							minchar = Bc[i];
						}
					}
				}
			}
			if (minchar == 'z') {
				continue;
			}
			count++;
			for (int i = 0; i < n; i++) {
				if (Ac[i] == curr && Bc[i] != curr) {
					Ac[i] = minchar;
				}
			}

		}

		Println(count);
	}

	/*
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 * 
	 */

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader(boolean b) throws FileNotFoundException {
			if (b) {
				br = new BufferedReader(new InputStreamReader(System.in));
			} else {
				br = new BufferedReader(new FileReader("src/input.txt"));
			}

		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static boolean isPrime(long n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (long i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}

	static void flush() {
		pw.flush();
	}

	static int _int() {
		return sc.nextInt();
	}

	static int[] _int(int n) {
		int[] Arr = new int[n];
		for (int i = 0; i < n; i++) {
			Arr[i] = sc.nextInt();
		}
		return Arr;
	}

	static int[][] _int(int m, int n) {
		int[][] Arr = new int[m][n];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				Arr[i][j] = sc.nextInt();
			}
		}
		return Arr;
	}

	static long _long() {
		return sc.nextLong();
	}

	static long[] _long(int n) {
		long[] Arr = new long[n];
		for (int i = 0; i < n; i++) {
			Arr[i] = sc.nextLong();
		}
		return Arr;
	}

	static long[][] _long(int m, int n) {
		long[][] Arr = new long[m][n];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				Arr[i][j] = sc.nextLong();
			}
		}
		return Arr;
	}

	static String _string() {
		return sc.next();
	}

	static String[] _string(int n) {
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		return s;
	}

	static char _char() {
		return sc.next().charAt(0);
	}

	static char[] _chars() {
		return sc.next().toCharArray();
	}

	static char[] _char(int n) {
		char[] c = new char[n];
		for (int i = 0; i < n; i++) {
			c[i] = sc.next().charAt(0);
		}
		return c;
	}

	static char[][] _chars(int n) {
		char[][] C = new char[n][];
		for (int i = 0; i < n; i++) {
			C[i] = _chars();
		}
		return C;
	}

	static char[][] _char(int m, int n) {
		char[][] C = new char[m][n];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				C[m][n] = sc.next().charAt(0);
			}
		}
		return C;
	}

	static int max(int m, int n) {
		return m > n ? m : n;
	}

	static int min(int m, int n) {
		return m < n ? m : n;
	}

	static long max(long m, long n) {
		return m > n ? m : n;
	}

	static long min(long m, long n) {
		return m < n ? m : n;
	}

	static int max(Iterable<Integer> A) {
		int ans = Integer.MIN_VALUE;
		for (int i : A) {
			if (i > ans) {
				ans = i;
			}
		}
		return ans;
	}

	static int min(Iterable<Integer> A) {
		int ans = Integer.MAX_VALUE;
		for (int i : A) {
			if (i < ans) {
				ans = i;
			}
		}
		return ans;
	}

	static int max(int... A) {
		int ans = Integer.MIN_VALUE;
		for (int i : A) {
			if (i > ans) {
				ans = i;
			}
		}
		return ans;
	}

	static int min(int... A) {
		int ans = Integer.MAX_VALUE;
		for (int i : A) {
			if (i < ans) {
				ans = i;
			}
		}
		return ans;
	}

	static long max(long... A) {
		long ans = Long.MIN_VALUE;
		for (long i : A) {
			if (i > ans) {
				ans = i;
			}
		}
		return ans;
	}

	static long min(long... A) {
		long ans = Long.MAX_VALUE;
		for (long i : A) {
			if (i < ans) {
				ans = i;
			}
		}
		return ans;
	}

	static void Println() {
		pw.println();
	}

	static void Println(Object X) {
		pw.println(X.toString());
	}

	static void Print(long x) {
		pw.print(x);
	}

	static void Println(long x) {
		pw.println(x);
	}

	static void Print(String s) {
		pw.print(s);
	}

	static void Println(String s) {
		pw.println(s);
	}

	static void Println(String[] A) {
		for (String s : A) {
			pw.println(s);
		}
	}

	static void Print(String[] A) {
		for (String s : A) {
			pw.print(s + " ");
		}
		pw.println();
	}

	static void Print(int[] A) {
		for (int i : A) {
			pw.print(i + " ");
		}
		pw.println();
	}

	static void Println(int[] A) {
		for (int i : A) {
			pw.println(i);
		}
	}

	static void Println(int[][] A) {
		for (int[] a : A) {
			for (int i : a) {
				pw.print(i + " ");
			}
			pw.println();
		}
	}

	static void Sort(int[] A) {
		Arrays.sort(A);
	}

	static void Sort(List<Integer> A) {
		Collections.sort(A);
	}

	static void Sortr(int[] A) {
		Arrays.sort(A);
		reverse(A);
	}

	static void reverse(int[] A) {
		int n = A.length;
		if (n < 2)
			return;
		int temp;
		for (int i = 0; i < n / 2; i++) {
			temp = A[i];
			A[i] = A[n - i - 1];
			A[n - i - 1] = temp;
		}
	}

	static void Sortr(List<Integer> A) {
		Collections.sort(A, Collections.reverseOrder());
	}

}
