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.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class COVID {

	static ArrayList<Integer>[] adjList;

	static int mod;
static int INF=(int)1e6;
static int n,k,l;
static int[][] dp;
static int[] shift;
static int[] d;
public static int solve(int idx , int t) {
	if(idx==n+1)return 1;
	if(t>(n+1)*2*k)return 0;
	
	if(idx>0&&d[idx-1]+shift[t%(2*k)]>l)return 0;
	if(dp[idx][t]!=-1)return dp[idx][t];
	int ans=0;
//	for(int i=1;i<=2*k;i++) {
//		int opt=1;
//		if(idx!=0&&i>1)
//		{
////			System.out.println("at idx "+idx+ " "+t+" "+(t+i-1)+" "+willSink(t, t+i-1)+" "+d[idx-1]);
//			opt&=(willSink(t, t+i-1)+d[idx-1]<=l)?1:0;
////			System.out.println(((willSink(t, t+i-1)+d[idx-1]<=l))&&(opt==1));
//		}
//		 opt&=solve(idx+1,t+i);
//		
//		ans|=opt;
//		if(ans==1)return dp[idx][t]=ans;
//	}
		
		if(idx==n||(shift[(t+1)%(2*k)]+d[idx]<=l))
			ans|=(solve(idx+1,t+1)|solve(idx,t+1));
		else
			ans|=solve(idx,t+1);
			
	
		return dp[idx][t]=ans;
	
}
public static int willSink(int s, int e) {
	if(s>=e)return 0;
	s%=2*k;
	e%=2*k;

	if(s<=e) {
		if(e<=k)return (shift[e]);
		if(s>=k)return shift[s];
		return k;
	}else {
		return Math.max(shift[s], shift[e]);
	}
}
public static void main(String[] args) throws Exception {

		Scanner	sc = new Scanner(System.in);
		PrintWriter pw= new PrintWriter(System.out);
		int t=sc.nextInt();
		h:while(t-->0) {
			int n=sc.nextInt();
			char[] a=sc.next().toCharArray();
			char[] b=sc.next().toCharArray();
			HashSet<Character> set=new HashSet<>();
			int ans=0;
			TreeSet<Character>[] mis=new TreeSet[26];
			for(int i=0;i<mis.length;i++) {
				mis[i]=new TreeSet<>();
			}
			
			for(int i=0;i<n;i++) {
				if(a[i]>b[i]) {
					pw.println(-1);
					continue h;
				}
				if(a[i]!=b[i]) {
					mis[a[i]-'a'].add(b[i]);
				}
		}
			for(int i=0;i<mis.length;i++) {
				Character cha=(char)('a'+i);
				mis[i].remove(cha);
				if(!mis[i].isEmpty()) {
					Character lo=mis[i].first();
					mis[i].remove(lo);
					ans++;
					for(Character c:mis[i]) {
						mis[lo-'a'].add(c);
					}
				}
			}
			pw.println(ans);
		}
			
		pw.close();
	}

	


	static long gcd(long a, long b) {
		return (b==0)?a:gcd(b,a%b);
	}
	static long lcm(long a, long b) {
		return a/gcd(a,b)*b;
	}
	public static int log(int n , int base) {
		int ans=0;
		while(n+1>base) {
			ans++;
			n/=base;
		}
		return ans;
	}
	static int pow(int b,long e) {
		int ans=1;
		while(e>0) {
			if((e&1)==1)
				ans=(int)((ans*1l*b));
			e>>=1;{

			}
			b=(int)((b*1l*b));
		}
		return ans;
	}
	static long powmod(long b,long e, int mod) {
		long ans=1;
		b%=mod;
		while(e>0) {
			if((e&1)==1)
				ans=(int)((ans*1l*b)%mod);
			e>>=1;
			b=(int)((b*1l*b)%mod);
		}
		return ans;
	}
	public static long add(long a, long b) {
		return (a+b)%mod;
	}
	public static long mul(long a, long b) {
		return ((a%mod)*(b%mod))%mod;
	}



static public class SegmentTree {
	int N;
	int[] array,sTree,lazy;
//	boolean[] marked; // if marked[i]=true this means that sTree[i] is the same value for all of it's children


	public SegmentTree(int[] arr) {//note arr must be 1 based arr
		array=arr;
		N=arr.length-1;// arr must be power of 2 and 1 based array
		sTree=new int[N<<1]; // no of nodes is 2N-1 but we add 1 to be 1 index
		lazy=new int[N<<1];
		//	marked=new boolean[N<<1];
//		build(1,1,N);

	}
	
public  void build(int v,int b ,int e) {//o(N)
		if(b==e) {
			sTree[v]=array[b];
		}else {
			int mid =(b+e)>>1;
		build((v<<1),b,mid);
		build((v<<1)|1,mid+1,e);

		sTree[v]=sTree[v<<1]+sTree[(v<<1)|1];	
		}
	}


	public int query(int i, int j) {//O(2log(n))
		return query(1, 1,N,i,j);
	}

	public int query(int node , int b ,int e , int i , int j) {
		if(b>j||e<i)return 0;
		if(b>=i&&e<=j)return sTree[node];
		int mid =(b+e)>>1;
		propagate(node, b, mid, e);// we propagate the delayed updated because we add left & right child 
		int leftChild =query(node<<1, b,mid,i,j);
		int rightChild =query((node<<1)|1, mid+1,e,i,j);
		return leftChild+rightChild;
	}

	public void set_point(int idx,int val) {
		idx+=N-1;
		sTree[idx]=val;
		while(idx>1) {
			idx>>=1;
		sTree[idx]=sTree[idx<<1]+sTree[idx<<1|1];
		}
	}


	public void update_point(int idx , int val) {
		idx+=N-1;
		sTree[idx]+=val;
		while(idx>1) {
			idx>>=1;//divide by 2 to get the parent
		sTree[idx]=sTree[(idx<<1)]+sTree[(idx<<1)|1];
		}

	}





	public void update_range(int i , int j , int val) {
		update_range(1,1, N, i,j,val);
	}



	public void update_range(int node,int b,int e ,int i , int j , int val) {
		if(e<i||b>j)return;
		if(b>=i&&e<=j) {
			sTree[node]+=(e-b+1)*val;
			lazy[node]+=val;

		}else {

			int mid =(b+e)>>1;
		propagate(node, b , mid , e);//we make propagate because after these call we make 	sTree[node]=sTree[node<<1]+sTree[node<<1 |1];
		// so it must be the correct value
		update_range(node<<1, b, mid, i, j, val);
		update_range(node<<1|1, mid+1, e, i, j, val);
		sTree[node]=sTree[node<<1]+sTree[node<<1 |1];
		}
	}


	public  void propagate(int node , int b ,int mid , int e) { //O(1)
		lazy[node<<1]+=lazy[node];
		lazy[node<<1|1]+=lazy[node];
		sTree[node<<1]+=(mid-b+1)*lazy[node];
		sTree[node<<1|1]+=(e-mid)*lazy[node];
		lazy[node]=0;
	}


}





	
static class Pair implements Comparable<Pair>{

		int  x;int y;



		public Pair(int a,int b) {
			this.x=a;y=b;
		}









		public int compareTo(Pair o) {
			return (x==o.x)?((y>o.y)?1:(y==o.y)?0:-1):((x>o.x)?1:-1);
			//		return y-o.y;
		}


		@Override




		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}


		@Override


		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

	}







	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public long[] nextLongArr(int n) throws IOException {
			long[] arr=new long[n];
			for(int i=0;i<n;i++)
				arr[i]=nextLong();
			return arr;
		}
		public int[] nextIntArr(int n) throws IOException {
			int[] arr=new int[n];
			for(int i=0;i<n;i++)
				arr[i]=nextInt();
			return arr;
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine()," ,");
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}


		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++) {
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
				if (sb.length() == 18) {
					res += Long.parseLong(sb.toString()) / f;
					sb = new StringBuilder("0");
				}
			}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

	public static void shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}
}