#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
typedef long long ll ;
typedef long double ld ;
typedef unsigned long long ull ;
typedef std::pair<int , int> pii ;
typedef std::pair<ll , ll> pll ;
typedef std::pair<ld , ld> pld ;
typedef std::vector<int> vi ;
typedef std::vector<char> vc ;
typedef std::vector<ll> vll ;
typedef std::vector<pii> vpi ;
typedef std::vector<pll> vpl ;
#define forn(i , a , b) for(int i = a ; i < b ; i ++)
#define sorn(i , a , b) for(int i = (a) - 1 ; i >= b ; i --)
#define rep(i , a) for(int i = 0 ; i < a ; i ++)
#define f first
#define s second
//#define endl "\n"
#define ins insert
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(tt) tt.begin() , tt.end()
#define read(x) scanf("%d", &x)
using namespace std ;
// int dx[4] = {1 , 0 , -1 , 0} ;
// int dy[4] = {0 , 1 , 0 , -1} ;
const int N = 2e5 + 10 ;
int a[N] , b[N] ;
int main ()
{
std::ios::sync_with_stdio(false) ;
std::cin.tie(0) ;
std::cout.tie(0) ;
int T ;
cin >> T ;
while (T --)
{
int n ;
cin >> n ;
string s ;
cin >> s ;
if(s == string(n, s[0]))
{
cout << "-1" << endl ;
continue ;
}
int ans = -1 ;
for(int i = 0 ; i < n - 1 ; i ++)
{
if(s[i] == 'R' && s[i + 1] == 'L')
{
ans = 0 ;
break ;
}
if (s[i] == 'L' && s[i + 1] == 'R')
{
ans = i + 1 ;
break ;
}
}
cout << ans << endl ;
}
return 0 ;
}
1302. Deepest Leaves Sum | 1209. Remove All Adjacent Duplicates in String II |
994. Rotting Oranges | 983. Minimum Cost For Tickets |
973. K Closest Points to Origin | 969. Pancake Sorting |
967. Numbers With Same Consecutive Differences | 957. Prison Cells After N Days |
946. Validate Stack Sequences | 921. Minimum Add to Make Parentheses Valid |
881. Boats to Save People | 497. Random Point in Non-overlapping Rectangles |
528. Random Pick with Weight | 470. Implement Rand10() Using Rand7() |
866. Prime Palindrome | 1516A - Tit for Tat |
622. Design Circular Queue | 814. Binary Tree Pruning |
791. Custom Sort String | 787. Cheapest Flights Within K Stops |
779. K-th Symbol in Grammar | 701. Insert into a Binary Search Tree |
429. N-ary Tree Level Order Traversal | 739. Daily Temperatures |
647. Palindromic Substrings | 583. Delete Operation for Two Strings |
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |