for _ in range(int(input())):
n,s=int(input()),input()
c=s[n//2]
for i in range(n//2,n):
if s[i]!=c:
break
else:i=n
print(2*i-n)
#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
cin>>t;
while(t--){
int n;
string s;
cin>>n>>s;
int k = n/2, i = k, j=k;
while(s[i+1]==s[k] and i<n-1)
i++;
while(j>=1 and s[j-1]==s[k])
j--;
cout<<i-j+1<<"\n";
}
}
///
454B - Little Pony and Sort by Shift | 1152A - Neko Finds Grapes |
1719B - Mathematical Circus | 1719C - Fighting Tournament |
1642A - Hard Way | 285C - Building Permutation |
1719E - Fibonacci Strings | 1696C - Fishingprince Plays With Array |
1085A - Right-Left Cipher | 1508B - Almost Sorted |
1690C - Restoring the Duration of Tasks | 1055A - Metro |
1036D - Vasya and Arrays | 1139C - Edgy Trees |
37A - Towers | 353A - Domino |
409H - A + B Strikes Back | 1262A - Math Problem |
158C - Cd and pwd commands | 194A - Exams |
1673B - A Perfectly Balanced String | 1104B - Game with string |
1169B - Pairs | 1567D - Expression Evaluation Error |
78A - Haiku | 1287A - Angry Students |
1428A - Box is Pull | 234B - Reading |
581B - Luxurious Houses | 1481C - Fence Painting |