Problem: Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter Koa selects must be strictly greater alphabetically than (read statement for better understanding). You can make hacks in these problems independently.
Koa the Koala has two strings and of the same length () consisting of the first lowercase English alphabet letters (ie. from a to t).
In one move Koa:
- selects some subset of positions ( if ) of such that (ie. all letters on this positions are equal to some letter ).
- selects a letter (from the first lowercase letters in English alphabet) such that (ie. letter is strictly greater alphabetically than ).
- sets each letter in positions to letter . More formally: for each () Koa sets . Note that you can only modify letters in string .
Koa wants to know the smallest number of moves she has to do to make strings equal to each other () or to determine that there is no way to make them equal. Help her!
Input Format: Each test contains multiple test cases. The first line contains () — the number of test cases. Description of the test cases follows.
The first line of each test case contains one integer () — the length of strings and .
The second line of each test case contains string ().
The third line of each test case contains string ().
Both strings consists of the first lowercase English alphabet letters (ie. from a to t).
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: 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 () or if there is no way to make them equal.
Note:
- In the -st test case Koa: selects positions and and sets b (). selects positions and and sets c ().
- In the -nd test case Koa has no way to make string equal .
- In the -rd test case Koa: selects position and sets t (). selects position and sets s (). selects position and sets r ().