```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
fmt.Fscan(in, &t)
for i := 0; i < t; i++ {
var n int
fmt.Fscan(in, &n)
var a, b string
fmt.Fscan(in, &a)
fmt.Fscan(in, &b)
c00, c01, c10, c11 := 0, 0, 0, 0
for j := 0; j < n; j++ {
if a[j] == '0' {
if b[j] == '0' {
c00++
} else {
c01++
}
} else {
if b[j] == '0' {
c10++
} else {
c11++
}
}
}
ans := -1
// Strategy 1: Even number of operations (pair swaps)
// We can fix mismatches if the count of (1,0) equals (0,1).
if c10 == c01 {
ans = 2 * c10
}
// Strategy 2: Odd number of operations
// Perform one operation on a matching '1' (type 11), then fix remaining with swaps.
// Requires c11 == c00 + 1. Cost is 1 + 2*c00.
if c11 == c00+1 {
res := 2*c00 + 1
if ans == -1 || res < ans {
ans = res
}
}
fmt.Fprintln(out, ans)
}
}
```