In order to write a string, Atilla needs to first learn all letters that are contained in the string.

Atilla needs to write a message which can be represented as a string $s$. He asks you what is the minimum alphabet size required so that one can write this message.

The alphabet of size $x$ ($1 \leq x \leq 26$) contains only the first $x$ Latin letters. For example an alphabet of size $4$ contains only the characters ${a}$, ${b}$, ${c}$ and ${d}$.


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 1000$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 100$) — the length of the string.

The second line of each test case contains a string $s$ of length $n$, consisting of lowercase Latin letters.


-----Output-----

For each test case, output a single integer — the minimum alphabet size required to so that Atilla can write his message $s$.


-----Examples-----

Input
5
1
a
4
down
10
codeforces
3
bcf
5
zzzzz
Output
1
23
19
6
26


-----Note-----

For the first test case, Atilla needs to know only the character ${a}$, so the alphabet of size $1$ which only contains ${a}$ is enough.

For the second test case, Atilla needs to know the characters ${d}$, ${o}$, ${w}$, ${n}$. The smallest alphabet size that contains all of them is $23$ (such alphabet can be represented as the string ${abcdefghijklmnopqrstuvw}$).

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Implementation

Greedy algorithms


Solutions:
test = int(input())
while test:
	n = int(input())
	s = input()
	print(ord(max(s)) - 96)
	test -= 1


t = int(input())
result = []
for i in range(t):
	n = int(input())
	s = input()
	arr = []
	arr.extend(s)
	arr.sort()
	result.append(arr[n - 1])
for i in result:
	print(ord(i) - ord('a') + 1)


nab = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for i in range(t):
	a = int(input())
	s = input()
	m = max(s)
	print(nab.find(m) + 1)


for i in range(int(input())):
	n = int(input())
	s = input()
	d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
	cnt = []
	news = set(s)
	for i in news:
		cnt.append(d[i])
	print(max(cnt))


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	print(ord(max(s)) - 96)
	t -= 1


numOfTc = int(input())
for i in range(numOfTc):
	size = int(input())
	string = input()
	print(ord(sorted(list(string))[-1]) - 97 + 1)


def main():
	t = int(input())
	for _ in range(t):
		(n, s) = (int(input()), input())
		print(ord(max(s)) - 96)
main()


t = int(input())
res = list()
for i in range(t):
	input()
	a = [ord(x) for x in input()]
	res.append(max(a) - ord('a') + 1)
print(*res, sep='\n')


n = int(input())
ans = []
for i in range(n):
	m = int(input())
	txt = input()
	ans.append(ord(max(txt)) - 96)
for i in ans:
	print(i)


t = input()
words = []
for i in range(int(t)):
	length = input()
	word = input()
	words.append(word)
for w in words:
	print(ord(max(w)) - 96)


for _ in range(int(input())):
	input()
	print(ord(max(input())) - ord('a') + 1)


def in_put():
	anynum = int(input())
	dc = input()
	dc_ascii = ord(max(dc)) - 32 - 64
	return dc_ascii

def main():
	t = int(input())
	res_li = []
	for i in range(t):
		res_li.append(in_put())
	for i in res_li:
		print(i)
main()


for s in [*open(0)][2::2]:
	print(ord(sorted(list(s))[-1]) - 96)


for _ in range(int(input())):
	n = int(input())
	s = input()
	print(max([ord(x) for x in s]) - 96)


alp = 'abcdefghijklmnopqrstuvwxyz'
for i in range(int(input())):
	n = int(input())
	s = sorted(list(input()))
	print(alp.index(s[-1]) + 1)


a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(int(input())):
	b = int(input())
	c = input()
	print(a.index(max(c)) + 1)


import math
for i in range(int(input())):
	n = int(input())
	s = input()
	a = 0
	for i in range(n):
		if ord(s[i]) > a:
			a = ord(s[i])
	print(a - 96)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
import math
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = inp()
for i in range(t):
	n = inp()
	s = st()
	s.sort()
	print(ord(s[-1]) - 96)


for __ in range(int(input())):
	s = int(input())
	l = input()
	print(ord(max(l)) - 97 + 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	s = sorted(s)
	print(ord(s[n - 1]) - 96)


dic = {}
for i in range(97, 97 + 26):
	dic[chr(i)] = i - 97 + 1
for i in range(int(input())):
	a = int(input())
	b = input()
	print(dic[max(b)])


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	a = sorted(a)
	alph = 'abcdefghijklmnopqrstuvwxyz'
	ans = alph.index(a[-1]) + 1
	print(ans)


n = int(input())
for i in range(n):
	size = int(input())
	string = [ord(s) - 96 for s in input()]
	print(max(string))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	s1 = max(s)
	print(ord(s1) - 96)


t = int(input())
while t:
	t -= 1
	input()
	s = input()
	mx = 'a'
	for i in range(0, len(s)):
		if s[i] > mx:
			mx = s[i]
	print(ord(mx) - ord('a') + 1)


for i in range(int(input())):
	a = int(input())
	s = input()
	k = max(s)
	print(ord(k) - 96)


for i in range(int(input())):
	n = int(input())
	a = input()
	max_ = 0
	for i in a:
		if ord(i) - ord('a') > max_:
			max_ = ord(i) - ord('a')
	print(max_ + 1)


hm = int(input())
for _ in range(hm):
	n = int(input())
	l = str(input())
	le = 0
	for i in l:
		if ord(i) - 96 > le:
			le = ord(i) - 96
	print(le)


n = int(input())
for _ in range(n):
	x = input()
	lets = [ord(i) for i in list(input())]
	print(max(lets) - 96)


for _ in range(int(input())):
	n = int(input())
	s = input()
	s = sorted(s)
	print(ord(s[-1]) - 96)


def lstRd() -> list:
	return list(map(int, input().split()))

def intRd():
	return int(input())

def lstStrRd():
	return list(input())
for _ in range(intRd()):
	n = intRd()
	print(max(list(map(ord, lstStrRd()))) - 96)


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	s.sort(reverse=True)
	print(ord(s[0]) - 96)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	ans = 1
	for j in s:
		if ord(j) - 96 > ans:
			ans = ord(j) - 96
	print(ans)


for _ in range(int(input())):
	size = int(input())
	word = list(input())
	ch = max(word)
	print(ord(ch) - 96)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(ord(max(s)) - ord('a') + 1)


for i in range(int(input())):
	n = int(input())
	s = list(input())
	s.sort()
	print(ord(s[-1]) - 96)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = ord(max(s))
	print(a - 96)


def solution():
	n = int(input())
	s = input()
	print(ord(max(s)) - ord('a') + 1)

def main():
	t = int(input())
	while t:
		solution()
		t -= 1
main()


t = int(input())
for i in range(t):
	n = int(input())
	st = input()
	max = 0
	for i in st:
		if ord(i) > max:
			max = ord(i)
	print(max - 96)


for i in range(int(input())):
	n = int(input())
	s = str(input())
	l = []
	l[0:] = s
	l.sort()
	print(abs(97 - ord(l[n - 1])) + 1)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	y = list(x)
	y.sort()
	c = y[n - 1]
	print(ord(c) - 96)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	maxi = s[0]
	for i in range(1, n):
		if maxi < s[i]:
			maxi = s[i]
	print(ord(maxi) - 96)


for i in range(int(input())):
	l = int(input())
	s = input()
	str = ''.join(sorted(s))
	x = str[l - 1]
	value = ord(x)
	print(value - 97 + 1)


t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	max = 0
	for j in range(0, n):
		if max <= ord(s[j]):
			max = ord(s[j])
	print(max - 96)


alp = 'abcdefghijklmnopqrstuvwxyz'
d = {}
c = 1
for i in alp:
	d[i] = c
	c += 1
t = int(input())
for j in range(t):
	l = int(input())
	s = input()
	s = list(s)
	s = sorted(s, reverse=True)
	print(d[s[0]])


t = int(input())
a = 'abcdefghijklmnopqrstuvwxyz'
for i in range(t):
	n = int(input())
	s = sorted(set(input()))
	print(a.index(s[len(s) - 1]) + 1)


from sys import stdin
for _ in range(int(stdin.readline().strip())):
	n = int(stdin.readline().strip())
	print(max(map(ord, list(stdin.readline().strip()))) - 96)


for i in range(int(input())):
	v = int(input())
	s = input()
	h = max(s)
	n = ord(h)
	print(n % 32)


t = int(input())
for _ in range(t):
	n = int(input())
	st = input()
	l = list(st)
	print(ord(max(l)) - ord('a') + 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = input('')
	max_ = a[0]
	for j in a:
		if j > max_:
			max_ = j
	print(ord(max_) - 96)


t = int(input())
for i in range(t):
	num = int(input())
	alpha = str(input())
	string = sorted(alpha)
	ind = string[num - 1]
	if ind == 'a':
		print(1)
	elif ind == 'b':
		print(2)
	elif ind == 'c':
		print(3)
	elif ind == 'd':
		print(4)
	elif ind == 'e':
		print(5)
	elif ind == 'f':
		print(6)
	elif ind == 'g':
		print(7)
	elif ind == 'h':
		print(8)
	elif ind == 'i':
		print(9)
	elif ind == 'j':
		print(10)
	elif ind == 'k':
		print(11)
	elif ind == 'l':
		print(12)
	elif ind == 'm':
		print(13)
	elif ind == 'n':
		print(14)
	elif ind == 'o':
		print(15)
	elif ind == 'p':
		print(16)
	elif ind == 'q':
		print(17)
	elif ind == 'r':
		print(18)
	elif ind == 's':
		print(19)
	elif ind == 't':
		print(20)
	elif ind == 'u':
		print(21)
	elif ind == 'v':
		print(22)
	elif ind == 'w':
		print(23)
	elif ind == 'x':
		print(24)
	elif ind == 'y':
		print(25)
	elif ind == 'z':
		print(26)


for _ in range(int(input())):
	n = int(input())
	mes = input()
	mes.upper()
	res = 0
	for item in mes:
		if ord(item) > res:
			res = ord(item)
	print(res - 96)


t = int(input())
for k in range(t):
	n = int(input())
	s = input()
	a = 'abcdefghijklmnopqrstuvwxyz'
	i = 1
	for j in range(26):
		if a[j] in s:
			i = j
	print(i + 1)


numberTimes = int(input())

def lengthRequired(data):
	data = sorted(data)
	data = data[-1]
	return ord(data) - ord('a') + 1
while numberTimes > 0:
	lenGth = int(input())
	data = input()
	print(lengthRequired(data))
	numberTimes -= 1


n = int(input())
d = dict(zip('abcdefghijklmnopqrstuvwxyz', range(1, 27)))
for i in range(n):
	len = int(input())
	s = input().lower()
	print(d[sorted(s)[::-1][0]])


t = int(input())
for ik in range(t):
	n = int(input())
	s = list(input())
	mm = max(s)
	print(ord(mm) - 96)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	s = sorted(s)
	res = s[-1]
	idx = alpha.index(res)
	print(idx + 1)


abc = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted([i for i in input()], reverse=True)
	ans = abc.find(s[0]) + 1
	print(ans)


for s in range(int(input())):
	n = int(input())
	s1 = input()
	max1 = 0
	for i in s1:
		if ord(i) - 96 > max1:
			max1 = ord(i) - 96
	print(max1)


t = int(input())
for i in range(t):
	length = int(input())
	s = [i for i in input()]
	print(ord(max(s)) - 96)


for _ in range(int(input())):
	n = int(input())
	s = input()
	for i in range(122, 96, -1):
		if chr(i) in s:
			print(i - 96)
			break


t = int(input())
i = 0
sol = []
while i < t:
	n = int(input())
	string = input()
	list = []
	for letter in string:
		list.append(letter)
	list.sort()
	sol.append(ord(list[n - 1]) - 96)
	i = i + 1
for s in sol:
	print(s)


n = int(input())
for i in range(n):
	t = int(input())
	li = input()
	x = ord(max(li)) - ord('a') + 1
	print(x)


k = '0abcdefghijklmnopqrstuvwxyz'
t = []
for i in range(int(input())):
	n = int(input())
	s = list(input())
	s.sort()
	s = s[-1]
	h = k.find(s)
	t.append(h)
for i in t:
	print(i)


T = int(input())
for i in range(T):
	N = int(input())
	L_word = [ord(i) for i in input()]
	L_word.sort()
	print(L_word[-1] - 96)


n = int(input())
a = []
for i in range(n):
	size = int(input())
	word = input()
	b = word[0]
	for i in range(size):
		if b < word[i]:
			b = word[i]
	a.append(b)
for i in a:
	print(ord(i) - 96)


t = int(input())
for i in range(t):
	n = int(input())
	v = input()
	c = sorted(v)
	x = c.pop()
	print(ord(x) - 96)


for i in range(int(input())):
	n = int(input())
	s = str(input())
	x = max(s)
	num = ord(x) - ord('a') + 1
	print(num)


alp = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
while t > 0:
	n = int(input())
	s = input()
	s = sorted(s)
	print(alp.index(s[-1]) + 1)
	t = t - 1


for i in range(int(input())):
	l = []
	n = int(input())
	s = input()
	s.lower()
	for j in s:
		l.append(ord(j) - 96)
	print(max(l))


import itertools
import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(s):
	print(ord(sorted(s)[-1]) - 96)
for i in range(inp()):
	length = invr()
	s = input()
	solve(s)


for i in range(int(input())):
	n = int(input())
	s = str(input())
	k = sorted(s)
	print(ord(k[-1]) - 96)


res = []
tc = int(input())
for i in range(tc):
	n = int(input())
	s = input()
	m = 0
	for j in range(n):
		o = ord(s[j]) - 96
		if o > m:
			m = o
	res.append(m)
for i in res:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	if len(s) == 1:
		print(ord(s[0]) - 96)
	else:
		res = ''.join(sorted(s))
		print(ord(res[-1]) - 96)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	max = 'a'
	for i in range(n):
		if s[i] > max:
			max = s[i]
	print(ord(max) - 97 + 1)
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	s = str(input())
	l = list(map(lambda j: j, s))
	print(ord(max(l)) - 96)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().lower()
	s = s.lower()
	m = max(s)
	print(ord(m) - 96)


t = int(input())
for i in range(t):
	n = int(input())
	m = input()
	m = list(m)
	m.sort()
	print(ord(m[-1]) - ord('a') + 1, end='\n')


for _ in range(int(input())):
	n = int(input())
	s = input()
	l = list(s)
	l.sort()
	p = ord(l[n - 1])
	print(abs(97 - p) + 1)


dict = {}
for i in range(26):
	dict[ord('a') + i] = i + 1
t = int(input())
for tt in range(t):
	n = int(input())
	s = input()
	ans = 0
	for c in s:
		ans = max(ans, dict[ord(c)])
	print(ans)


t = int(input())
for i in range(t):
	l = int(input())
	s = input()
	s = s.replace('', ' ')
	s = s.split()
	lst = [ord(x) for x in s]
	print(max(lst) - 96)


n1 = int(input())
i1 = 0
f1 = 0
while i1 < n1:
	f1 = 0
	i1 = i1 + 1
	a1 = int(input())
	s1 = input()
	if len(s1) == a1:
		for j1 in s1:
			if ord(j1) > f1:
				f1 = ord(j1)
		print(f1 - 96)
	else:
		print('invalid')


for t in range(int(input())):
	a = int(input())
	n = input()
	b = ''.join(sorted(n))
	c = b[-1]
	print(ord(c) - 96)


t = int(input().strip())
for x in range(t):
	n = int(input().strip())
	l = list(input())
	m = max(l)
	print(ord(m) - ord('a') + 1 if ord(m) > ord('a') else 1)


for _ in range(int(input())):
	n = int(input())
	string = input()
	mmax = max(string)
	print(ord(mmax) % 97 + 1)