```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func nextPermutation(a []byte) bool {
i := len(a) - 2
for i >= 0 && a[i] >= a[i+1] {
i--
}
if i < 0 {
return false
}
j := len(a) - 1
for a[j] <= a[i] {
j--
}
a[i], a[j] = a[j], a[i]
for l, r := i+1, len(a)-1; l < r; l, r = l+1, r-1 {
a[l], a[r] = a[r], a[l]
}
return true
}
func gen(s string) []string {
a := []byte(s)
res := []string{string(a)}
for nextPermutation(a) {
res = append(res, string(a))
}
return res
}
func main() {
in := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
perms := make(map[int][]string)
for _, n := range []int{12, 123, 1234} {
perms[n] = gen(strconv.Itoa(n))
}
var t int
fmt.Fscan(in, &t)
for ; t > 0; t-- {
var n, j, k int
fmt.Fscan(in, &n, &j, &k)
a := perms[n][j-1]
b := perms[n][k-1]
x := 0
for i := 0; i < len(a); i++ {
if a[i] == b[i] {
x++
}
}
fmt.Fprintf(out, "%dA%dB\n", x, len(a)-x)
}
}
```