Given a string A of length N consisting of lowercase English alphabet letters. 

You are allowed to perform the following operation on the string A any number of times: 

Select a non-empty [subsequence] S of the array [1,2,3,\ldots,N] and any lowercase English alphabet \alpha;
Change A_{i} to \alpha for all i \in S.

Find the minimum number of operations required to convert A into a given string B of length N consisting of lowercase English alphabet letters. 

------ Input Format ------ 

- The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follow.
- The first line of each test case contains an integer N - the length of the string A and B.
- The second line of each test case contains the string A. 
- The third line of each test case contains the string B. 

------ Output Format ------ 

For each test case, output the minimum number of operations required to convert string A into string B. 

------ Constraints ------ 

$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
- Sum of $N$ over all test cases does not exceed $10^{5}$.

----- Sample Input 1 ------ 
3
2
ab
cd
3
aaa
bab
4
abcd
aaab

----- Sample Output 1 ------ 
2
1
2

----- explanation 1 ------ 
Test case 1:
- In the first operation, we can choose $S = \{1\}$ and $\alpha =$ c. After this operation, $A$ will become cb.
- In the second operation, we can choose $S = \{2\}$ and $\alpha =$ d. After this operation, $A$ will become cd. 

Test case 2: 
- In the first operation, we can choose $S = \{1, 3\}$ and $\alpha =$ b. After this operation, $A$ will become bab.

Test case 3:
- In the first operation, we can choose $S = \{2, 3\}$ and $\alpha =$ a. After this operation, $A$ will become aaad.
- In the second operation, we can choose $S = \{4\}$ and $\alpha =$ b. After this operation, $A$ will become aaab.

Source: codechef | Difficulty: EASY
Tags: Implementation


Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	x = []
	y = []
	for i in range(n):
		if a[i] == b[i]:
			x.append(1)
		else:
			x.append(0)
			y.append(b[i])
	else:
		print(x.count(0) - len(y) + len(set(y)))


t = int(input())
while t > 0:
	N = int(input())
	list = []
	A = input()
	B = input()
	for i in range(N):
		if A[i] != B[i]:
			if B[i] not in list:
				list.append(B[i])
	print(len(list))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	s = set()
	for i in range(n):
		if a[i] != b[i]:
			s.add(b[i])
	print(len(s))


for i in range(int(input())):
	n = int(input())
	A = input()
	B = input()
	s = set()
	for i in range(n):
		if A[i] != B[i]:
			s.add(B[i])
	print(len(s))


for _ in range(int(input())):
	lent = int(input())
	arr1 = list(input())
	arr2 = list(input())
	blank_a = []
	i = 0
	count = 0
	for o in range(lent):
		if arr1[i] != arr2[i]:
			if arr2[i] not in blank_a:
				blank_a.append(arr2[i])
				count += 1
		i += 1
	print(count)


s = int(input())
for i in range(s):
	a = int(input())
	b = input()
	c = input()
	lst = []
	for j in range(a):
		if b[j] != c[j]:
			lst.append(c[j])
	print(len(set(lst)))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	d = {}
	for j in range(n):
		if a[j] != b[j]:
			if b[j] in d:
				d[b[j]] += 1
			else:
				d[b[j]] = 1
	print(len(d))


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	seq = []
	match = []
	for i in range(n):
		if a[i] == b[i]:
			seq.append(1)
		else:
			seq.append(0)
			match.append(b[i])
	else:
		print(seq.count(0) - len(match) + len(set(match)))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	c = []
	for i in range(n):
		if a[i] == b[i]:
			pass
		else:
			c.append(b[i])
	print(len(set(c)))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	s = []
	c = []
	for i in range(n):
		if a[i] == b[i]:
			s.append(1)
		else:
			s.append(0)
			c.append(b[i])
	print(len(set(c)))


for _ in range(int(input())):
	n = int(input())
	s1 = input('')
	s2 = input('')
	s = set()
	for i in range(n):
		if s1[i] != s2[i]:
			s.add(s2[i])
	print(len(s))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = input()[:n]
	b = input()[:n]
	k = 0
	x = []
	for i in range(n):
		if b[i] != a[i]:
			if b[i] not in x:
				a = a.replace(a[i], a[i], len(a))
				x.append(b[i])
				k = k + 1
	print(k)


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	s = set()
	for j in range(n):
		if s1[j] != s2[j]:
			s.add(s2[j])
	print(len(s))


for i in range(int(input())):
	N = int(input())
	A = input()
	B = input()
	x = []
	y = []
	for i in range(N):
		if A[i] == B[i]:
			x.append('s')
		else:
			x.append('n')
			y.append(B[i])
	print(len(set(y)) + x.count('n') - len(y))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	s = []
	m = []
	for j in range(n):
		if a[j] == b[j]:
			s.append(1)
		else:
			s.append(0)
			m.append(b[j])
	else:
		print(s.count(0) - len(m) + len(set(m)))


for T in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	same_index = []
	for i in range(n):
		if a[i] == b[i]:
			same_index.append(i)
	unique_alp = []
	for i in range(n):
		if i in same_index:
			continue
		elif b[i] in unique_alp:
			continue
		else:
			unique_alp.append(b[i])
	print(len(unique_alp))


for i in range(int(input())):
	x = int(input())
	s1 = input()
	s2 = input()
	c = 0
	l = set()
	for i in range(x):
		if s1[i] == s2[i]:
			c += 1
		else:
			l.add(s2[i])
	print(len(l))


for i in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	l = []
	for i in range(n):
		if s1[i] != s2[i]:
			l.append(s2[i])
	print(len(set(l)))


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	ca = []
	cb = []
	for i in range(n):
		if a[i] == b[i]:
			ca.append(1)
		else:
			ca.append(0)
			cb.append(b[i])
	print(ca.count(0) - len(cb) + len(set(cb)))


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = 0
	l = []
	for i in range(n):
		if a[i] != b[i]:
			c += 1
			l.append(i)
	x = []
	for i in l:
		if b[i] not in x:
			x.append(b[i])
	print(len(x))


for i in range(int(input())):
	N = int(input())
	A = input()
	B = input()
	c = 0
	l = []
	for j in range(N):
		if A[j] != B[j]:
			c += 1
			l.append(j)
	x = []
	for j in l:
		if B[j] not in x:
			x.append(B[j])
	print(len(x))


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	b = input()
	characters = []
	for i in range(n):
		if a[i] != b[i]:
			if b[i] not in characters:
				characters.append(b[i])
	print(len(characters))


for _ in range(int(input())):
	n = int(input())
	s = input()
	s1 = input()
	l = []
	for i in range(n):
		if s[i] != s1[i]:
			l.append(s1[i])
	print(len(set(l)))


for i in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	l = []
	for j in range(n):
		if a[j] != b[j]:
			l.append(b[j])
	print(len(set(l)))


t = int(input())
for i in range(t):
	n = int(input())
	A = input()
	B = input()
	moves = set()
	for j in range(n):
		if A[j] != B[j]:
			moves.add(B[j])
	print(len(moves))


t = int(input())
for tc in range(t):
	n = int(input())
	a = input()
	b = input()
	s = []
	for k in range(n):
		if a[k] != b[k]:
			s.append(b[k])
	print(len(set(s)))


q = int(input())
for i in range(q):
	n = int(input())
	a = input()
	b = input()
	la = [j for j in a]
	lb = [k for k in b]
	count = 0
	l = []
	for t in range(n):
		if la[t] != lb[t]:
			l.append(lb[t])
	print(len(set(l)))


for i in range(int(input())):
	a = int(input())
	s = input()
	d = input()
	k = []
	for i in range(a):
		if s[i] != d[i]:
			k.append(d[i])
	print(len(set(k)))


for i in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = []
	for i in range(n):
		if a[i] != b[i]:
			c.append(b[i])
	print(len(set(c)))


t = int(input())
for i in range(0, t):
	n = int(input())
	a = str(input())
	b = str(input())
	y = []
	for i in range(n):
		if a[i] != b[i]:
			y.append(b[i])
	print(len(set(y)))


for _ in range(int(input())):
	count = 0
	n = int(input())
	a = input()
	b = input()
	str = []
	for i in range(n):
		if a[i] != b[i]:
			str.append(b[i])
	z = set(str)
	for i in z:
		count += 1
	print(count)


for i in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = ''
	r = 0
	for i in range(n):
		if a[i] != b[i] and b[i] not in c:
			c = c + b[i]
			r += 1
	print(r)


for t in range(int(input())):
	n = int(input())
	a = str(input())
	b = str(input())
	l = []
	for i in range(n):
		if a[i] != b[i]:
			l.append(b[i])
	print(len(set(l)))


for i in range(int(input())):
	c = 0
	n = int(input())
	a = input()
	b = input()
	l = []
	for i in range(n):
		if a[i] != b[i]:
			l.append(b[i])
	z = set(l)
	for i in z:
		c = c + 1
	print(c)


for i in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	k = 0
	u = []
	for i in range(n):
		if a[i] != b[i]:
			if b[i] not in u:
				u.append(b[i])
	print(len(u))


def test(a, b, s, n, k):
	for i in range(s):
		if a[i] != b[i]:
			if b[i] not in n:
				n.append(b[i])
	return len(n)
for i in range(int(input())):
	s = int(input())
	a = input()
	b = input()
	k = 0
	n = []
	result = test(a, b, s, n, k)
	print(result)


for _ in range(int(input())):
	lenstr = int(input())
	initial = input()
	final = input()
	topush = []
	for i in range(lenstr):
		if initial[i] != final[i]:
			if final[i] not in topush:
				topush.append(final[i])
	print(len(topush))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	x = []
	for i in range(n):
		if a[i] != b[i]:
			x.append(b[i])
	x = list(set(x))
	print(len(x))


import os, sys, io, math
from re import *
from math import *
from array import *
from heapq import *
from bisect import *
from functools import *
from itertools import *
from statistics import *
from collections import *
I = lambda : [*map(int, sys.stdin.readline().split())]
IP = lambda : map(int, input().split())
IS = lambda : input()
IN = lambda : int(input())
IF = lambda : float(input())

def f():
	(n, a, b) = (IN(), IS(), IS())
	r = []
	c = 0
	for i in range(n):
		if a[i] == b[i]:
			pass
		elif b[i] not in r:
			r.append(b[i])
			c += 1
	return c
for _ in range(IN()):
	print(f())


for _ in range(int(input())):
	(N, A, B) = (int(input()), input(), input())
	a = b = ''
	for i in range(N):
		if A[i] != B[i]:
			a = a + A[i]
			b = b + B[i]
	print(len(set(b.lower())))


for t in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	d = {}
	for i in range(n):
		if a[i] != b[i]:
			if b[i] not in d:
				d[b[i]] = 1
	print(len(d.keys()))


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	b1 = ''
	for i in range(n):
		if a[i] != b[i]:
			b1 += b[i]
	print(len(set(b1)))


def equal_string(string1, string2, length):
	new_string = ''
	for i in range(length):
		if string1[i] != string2[i]:
			if string2[i] not in new_string:
				new_string += string2[i]
	return len(new_string)
for i in range(int(input())):
	length = int(input())
	string1 = input()
	string2 = input()
	print(equal_string(string1, string2, length))


t = int(input())
for t in range(t):
	n = int(input())
	a = input()
	b = input()
	d = {}
	i = 0
	while i < n:
		if a[i] != b[i]:
			if b[i] in d:
				d[b[i]] += 1
			else:
				d[b[i]] = 1
		i = i + 1
	print(len(d))


import string
t = int(input())
for i in range(t):
	N = int(input())
	s1 = input()
	s2 = input()
	s22 = ''
	for i in range(N):
		if s1[i] != s2[i]:
			s22 += s2[i]
	print(len(set(s22)))


def solution():
	M = [0 for i in range(26)]
	N = int(input())
	A = input()
	B = input()
	for i in range(N):
		if B[i] != A[i]:
			M[ord(B[i]) - ord('a')] = 1
	print(sum(M))
T = int(input())
for i in range(T):
	solution()


t = int(input())
while t > 0:
	n = int(input())
	s1 = input()
	s2 = input()
	k = ''
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			k = k + s2[i]
	print(len(set(k)))
	t = t - 1


t = int(input())
while t != 0:
	n = int(input())
	a = input()
	b = input()
	c = 0
	l = []
	for i in range(len(b)):
		if b[i] != a[i]:
			l.append(b[i])
	print(len(set(l)))
	t -= 1


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	temp_a = [ele for ele in a]
	temp_b = [ele for ele in b]
	f_a = []
	f_b = []
	for i in range(n):
		if temp_a[i] != temp_b[i]:
			f_a.append(temp_a[i])
			f_b.append(temp_b[i])
	c = Counter(f_b)
	flag = 0
	for i in range(len(f_b) - 1):
		if f_b[i] != f_b[i + 1]:
			flag += 1
	if flag == 0:
		print(1)
	else:
		print(len(c))