Algorithm


B. Atilla's Favorite Problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 (1x261≤�≤26) contains only the first x Latin letters. For example an alphabet of size 44 contains only the characters aabbcc and dd.

Input

The first line contains a single integer t (1t10001≤�≤1000) — the number of test cases.

The first line of each test case contains a single integer n (1n1001≤�≤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.

Example
input
Copy
5
1
a
4
down
10
codeforces
3
bcf
5
zzzzz
output
Copy
1
23
19
6
26
Note

For the first test case, Atilla needs to know only the character aa, so the alphabet of size 11 which only contains aa is enough.

For the second test case, Atilla needs to know the characters ddoowwnn. The smallest alphabet size that contains all of them is 2323 (such alphabet can be represented as the string abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw).

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans = 0;
    for(int i = 0; i < n; i++){
      ans = max(ans, s[i] - 'a' + 1);
    }
    cout<<ans<<endl;
  }

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5
1
a
4
down
10
codeforces
3
bcf
5
zzzzz

Output

x
+
cmd
1
23
19
6
26
Advertisements

Demonstration


Codeforcess Solution 1760-B B. Atilla's Favorite Problem ,C++, Java, Js and Python,1760-B,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+