/**
* author: Ashif Akhtar
**/
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define sync ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
#define pb push_back
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const ll mod = 1000000007;
#define endl "\n"
#define in(x , n) for (auto &i : x)cin >> i;
#define out(x , n) for (int i = 0; i < n; i++)cout << x[i] << " \n"[i == n - 1];
#define pi 3.14159265358979323846
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pb;
#define fo find_by_order
#define ok order_of_key
#define ins insert
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); }
int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[] = {1, 0, -1, 0, -1, 1, 1, -1};
void solve()
{
int n;
string s;
cin >> n >> s;
map<char, int>m1, m2;
for (int i = 0; i < n; ++i)
{
m1[s[i]]++;
}
int ans1 = m1.size();
int ans2 = 0;
int Ans = ans1;
for (int i = 0; i < n; ++i)
{
m1[s[i]]--;
if (m1[s[i]] == 0)ans1--;
m2[s[i]]++;
ans2 = m2.size();
Ans = max(ans1 + ans2, Ans);
}
cout << Ans << endl;
}
signed main()
{
sync;
int t = 1;
cin >> t;
for (int i = 1; i <= t; ++i)
{
// cout << "Case #" << i << ": ";
solve();
}
return 0;
}
63A - Sinking Ship | 1704B - Luke is a Foodie |
298B - Sail | 239A - Two Bags of Potatoes |
1704E - Count Seconds | 682A - Alyona and Numbers |
44A - Indian Summer | 1133C - Balanced Team |
1704A - Two 0-1 Sequences | 1467A - Wizard of Orz |
1714E - Add Modulo 10 | 1714A - Everyone Loves to Sleep |
764A - Taymyr is calling you | 1714B - Remove Prefix |
1264F - Beautiful Fibonacci Problem | 52A - 123-sequence |
1543A - Exciting Bets | 1714D - Color with Occurrences |
215B - Olympic Medal | 1445A - Array Rearrangment |
1351A - A+B (Trial Problem) | 935B - Fafa and the Gates |
1291A - Even But Not Even | 1269A - Equation |
441A - Valera and Antique Items | 1702C - Train and Queries |
816B - Karen and Coffee | 838D - Airplane Arrangements |
148B - Escape | 847G - University Classes |