```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var t int
fmt.Fscan(reader, &t)
for ; t > 0; t-- {
var n int
fmt.Fscan(reader, &n)
var s string
fmt.Fscan(reader, &s)
// Raze picks from odd positions (1-indexed), i.e., indices 0, 2, 4, ... (0-indexed)
// Breach picks from even positions (1-indexed), i.e., indices 1, 3, 5, ... (0-indexed)
// Raze wants the last remaining digit to be odd
// Breach wants the last remaining digit to be even
// Count digits on odd positions (1-indexed) and even positions (1-indexed)
// Odd positions (1-indexed) = indices 0, 2, 4, ... (0-indexed)
// Even positions (1-indexed) = indices 1, 3, 5, ... (0-indexed)
oddPosCount := 0 // count of digits at odd positions (1-indexed)
evenPosCount := 0 // count of digits at even positions (1-indexed)
for i := 0; i < n; i++ {
if (i+1)%2 == 1 {
oddPosCount++
} else {
evenPosCount++
}
}
// Raze removes from odd positions, Breach removes from even positions
// They alternate, Raze first. Total turns = n - 1
// Raze makes ceil((n-1)/2) turns, Breach makes floor((n-1)/2) turns
// Raze removes from odd positions: she removes (oddPosCount - x) digits from odd positions
// where x is how many odd-position digits remain
// Breach removes from even positions: he removes (evenPosCount - y) digits from even positions
// After all turns, exactly 1 digit remains.
// Raze makes ceil((n-1)/2) removals from odd positions
// Breach makes floor((n-1)/2) removals from even positions
// But wait: Raze can only remove from odd positions. She has oddPosCount digits available.
// She needs to make ceil((n-1)/2) removals. But she might not have enough odd-position digits.
// Actually the problem says "It can be proved that before the end each agent has ability to make a turn"
// So we can trust counts work out.
// Raze removes ceil((n-1)/2) digits from odd positions
// Breach removes floor((n-1)/2) digits from even positions
// After removal:
// Remaining odd-position digits: oddPosCount - ceil((n-1)/2)
// Remaining even-position digits: evenPosCount - floor((n-1)/2)
// Total remaining = 1
razeTurns := (n - 1 + 1) / 2 // ceil((n-1)/2)
breachTurns := (n - 1) / 2 // floor((n-1)/2)
remainOdd := oddPosCount - razeTurns
remainEven := evenPosCount - breachTurns
// Exactly one of remainOdd, remainEven should be 1 and the other 0
_ = remainEven
if remainOdd == 1 {
// The last digit is from odd positions. Raze wants it odd.
// Raze is removing digits from odd positions to leave one she likes (odd digit)
// She plays optimally: she removes even digits from odd positions first.
// She wants to keep an odd digit. Does any odd-position digit have an odd value?
hasOdd := false
for i := 0; i < n; i += 2 {
if (s[i]-'0')%2 == 1 {
hasOdd = true
break
}
}
if hasOdd {
fmt.Fprintln(writer, 1)
} else {
fmt.Fprintln(writer, 2)
}
} else {
// The last digit is from even positions. Breach controls it.
// Breach wants to keep an even digit.
hasEven := false
for i := 1; i < n; i += 2 {
if (s[i]-'0')%2 == 0 {
hasEven = true
break
}
}
if hasEven {
fmt.Fprintln(writer, 2)
} else {
fmt.Fprintln(writer, 1)
}
}
}
}
```