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 sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
        self.BUFSIZE = 8192

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


def get_int():
    return int(input())


def get_ints():
    return list(map(int, input().split(' ')))


def get_int_grid(n):
    return [get_ints() for _ in range(n)]


def get_str():
    return input().split(' ')


def yes_no(b):
    if b:
        return "YES"
    else:
        return "NO"


def binary_search(good, left, right, delta=1, right_true=False):
    """
    Performs binary search
    ----------
    Parameters
    ----------
    :param good: Function used to perform the binary search
    :param left: Starting value of left limit
    :param right: Starting value of the right limit
    :param delta: Margin of error, defaults value of 1 for integer binary search
    :param right_true: Boolean, for whether the right limit is the true invariant
    :return: Returns the most extremal value interval [left, right] which is good function evaluates to True,
            alternatively returns False if no such value found
    """

    limits = [left, right]
    while limits[1] - limits[0] > delta:
        if delta == 1:
            mid = sum(limits) // 2
        else:
            mid = sum(limits) / 2
        if good(mid):
            limits[int(right_true)] = mid
        else:
            limits[int(~right_true)] = mid
    if good(limits[int(right_true)]):
        return limits[int(right_true)]
    else:
        return False


def prefix_sums(a, drop_zero=False):
    p = [0]
    for x in a:
        p.append(p[-1] + x)
    if drop_zero:
        return p[1:]
    else:
        return p


def prefix_mins(a, drop_zero=False):
    p = [float('inf')]
    for x in a:
        p.append(min(p[-1], x))
    if drop_zero:
        return p[1:]
    else:
        return p


class DSU:

    # Disjoint Set Union (Union-Find) Data Structure
    def __init__(self, nodes):
        # Parents
        self.p = {i: i for i in nodes}
        # Ranks
        self.r = {i: 0 for i in nodes}
        # Sizes
        self.s = {i: 1 for i in nodes}

    def get(self, u):
        # Recursive Returns the identifier of the set that contains u, includes path compression
        if u != self.p[u]:
            self.p[u] = self.get(self.p[u])
        return self.p[u]

    def union(self, u, v):
        # Unites the sets with identifiers u and v
        u = self.get(u)
        v = self.get(v)
        if u != v:
            if self.r[u] > self.r[v]:
                u, v = v, u
            self.p[u] = v
            if self.r[u] == self.r[v]:
                self.r[v] += 1
            self.s[v] += self.s[u]


def solve():
    n = get_int()
    s1 = input().strip()
    s2 = input().strip()
    G = defaultdict(list)
    for letter in list(string.ascii_lowercase)[:20]:
        top_set = set(s2[i] for i in range(n) if s1[i] == letter)
        if len(top_set) == 0:
            pass
        else:
            for item in top_set:
                if item < letter:
                    return -1
                elif item > letter:
                    G[item].append(letter)
                    G[letter].append(item)

    dsu = DSU(G.keys())
    for x in G:
        for y in G[x]:
            dsu.union(x, y)
    S = 0
    for x in G:
        if dsu.p[x] == x:
            S += dsu.s[x] - 1
    return S



t = get_int()
for _ in range(t):
    print(solve())