```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
var t int
if _, err := fmt.Fscan(in, &t); err != nil {
return
}
for k := 0; k < t; k++ {
var n int
if _, err := fmt.Fscan(in, &n); err != nil {
break
}
var c string
if _, err := fmt.Fscan(in, &c); err != nil {
break
}
// If n is odd, the answer is always YES
if n%2 != 0 {
fmt.Fprintln(out, "YES")
continue
}
// If n is even, check for obstructions
hasRR := false
hasBB := false
countR := 0
countB := 0
for i := 0; i < n; i++ {
if c[i] == 'R' {
countR++
} else {
countB++
}
// Check adjacent edge colors
next := i + 1
if next == n {
next = 0
}
if c[i] == c[next] {
if c[i] == 'R' {
hasRR = true
} else {
hasBB = true
}
}
}
if hasRR && hasBB {
// Contains both "RR" and "BB" -> disconnected
fmt.Fprintln(out, "NO")
} else if !hasRR && !hasBB {
// Alternating colors -> disconnected
fmt.Fprintln(out, "NO")
} else {
// Only "RR" or only "BB" exists.
// The isolated characters must appear an odd number of times (or 0) for YES.
if hasRR {
// Only RR exists, check count of B
// If countB is even and > 0, it's NO
if countB > 0 && countB%2 == 0 {
fmt.Fprintln(out, "NO")
} else {
fmt.Fprintln(out, "YES")
}
} else {
// Only BB exists, check count of R
if countR > 0 && countR%2 == 0 {
fmt.Fprintln(out, "NO")
} else {
fmt.Fprintln(out, "YES")
}
}
}
}
}
```