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 javax.swing.*;
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static long[] tree;
    static int m = 100000000;
    static int k1,k2;
    static boolean[] vis;
    static tuple[] tuples;
    public static void main(String[] args) throws IOException {
        //BufferedReader reader=new BufferedReader(new FileReader("input.txt"));
        //PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //Scanner sc=new Scanner(System.in);
        //Reader sc = new Reader();
        int t=Integer.parseInt(reader.readLine());
        for (int k = 0; k <t ; k++) {
            int n=Integer.parseInt(reader.readLine());
            char[] a=reader.readLine().toCharArray();
            char[] b=reader.readLine().toCharArray();
            boolean flag=false;
            for (int i = 0; i <a.length ; i++) {
                if (b[i]<a[i]) {
                    flag = true;
                    break;
                }
            }
            if (flag)
                out.println(-1);
            else {
                int count=0;
                for (int i = 97; i <118 ; i++) {
                    Vector<Integer> v=new Vector<>();
                    int x=30;
                    for (int j = 0; j <a.length ; j++) {
                        if (a[j]==i && a[j]!=b[j]){
                            v.add(j);
                            x=Math.min(x,b[j]-a[j]);
                        }
                    }
                    //out.println(v);
                    if (!v.isEmpty()){
                        count++;
                        for (int ix:v) {
                            a[ix]=(char) (a[ix]+x);
                        }
                    }

                }
                out.println(count);
            }
        }









        out.close();
    }
    static boolean bfs(int a,int b){
        Queue<Integer> queue=new LinkedList<>();
        queue.add(a);

        while (!queue.isEmpty()){
            int now=queue.poll();
            vis[now]=true;

            for (int i = 0; i <k1 ; i++) {
                if (!vis[i]){
                    if((tuples[i].a<tuples[now].a&&tuples[now].a<tuples[i].b)
                                ||(tuples[i].a<tuples[now].b&&tuples[now].b<tuples[i].b)){
                        queue.add(i);
                        if (i==b){
                            Arrays.fill(vis,false);
                            return true;
                        }
                    }
                }
            }
        }

        Arrays.fill(vis,false);
        return false;

    }
    static int find(int[] p,int x){
        if (p[x]==x)return x;

        return p[x]=find(p,p[x]);
    }
    static void union(int[] p,int a,int b){
        p[find(p,b)]=find(p,a);
    }
    static void built(long[] a,int at,int l,int r,int n){
        if (l==r){
            tree[at]=a[l];
        }
        else {
            int mid=(l+r)/2;
            int right=2*at;
            int left=(2*at)+1;
            built(a,left,l,mid,n-1);
            built(a,right,mid+1,r,n-1);
            if (n%2==0)
                tree[at]=tree[left]^tree[right];
            else
                tree[at]=tree[left]|tree[right];
        }
    }
    static void update(int at,int l,int r,int i,long v,int n){
        if (i<l || i>r)return;

        if (l==r){
            tree[at]=v;
        }
        else {
            int mid=(l+r)/2;
            int right=2*at;
            int left=(2*at)+1;
            update(left,l,mid,i,v,n-1);
            update(right,mid+1,r,i,v,n-1);
            if (n%2==0)
                tree[at]=tree[left]^tree[right];
            else
                tree[at]=tree[left]|tree[right];
        }
    }




}

    class node implements Comparable<node> {
        Integer no;
        Integer cost;
        Vector<node> adj = new Vector<>();

        public node(Integer no, Integer cost) {
            this.no = no;
            this.cost = cost;
        }

        @Override
        public String toString() {
            return "node{" +
                    "no=" + no +
                    ", cost=" + cost +
                    '}';
        }

        @Override
        public int compareTo(node o) {
            return o.cost - this.cost;
        }
    }

    class edge implements Comparable<edge> {
        tuple u;
        Double cost;

        public edge(tuple u, Double cost) {
            this.u = u;
            this.cost = cost;
        }

        @Override
        public int compareTo(edge o) {
            return this.cost.compareTo(o.cost);
        }

        @Override
        public String toString() {
            return "edge{" +
                    "u=" + u +
                    ", cost=" + cost +
                    '}';
        }
    }

    ///*
    class tuple implements Comparable<tuple> {
        Integer a;
        Integer b;

        public tuple(Integer a, Integer b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(tuple o) {
            return (int) (this.b - o.b);
        }

        @Override
        public String toString() {
            return "tuple{" +
                    "a=" + a +
                    ", b=" + b +
                    '}';
        }
    }


    //*/
    class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }