package main
import (
"bufio"
"fmt"
"os"
)
type FastScanner struct {
r *bufio.Reader
}
func NewFastScanner() *FastScanner {
return &FastScanner{r: bufio.NewReaderSize(os.Stdin, 1<<20)}
}
func (fs *FastScanner) NextInt() int {
sign, val := 1, 0
c, err := fs.r.ReadByte()
for (c < '0' || c > '9') && c != '-' {
c, err = fs.r.ReadByte()
if err != nil {
return 0
}
}
if c == '-' {
sign = -1
c, _ = fs.r.ReadByte()
}
for c >= '0' && c <= '9' {
val = val*10 + int(c-'0')
c, err = fs.r.ReadByte()
if err != nil {
break
}
}
if err == nil {
_ = fs.r.UnreadByte()
}
return sign * val
}
func main() {
in := NewFastScanner()
out := bufio.NewWriterSize(os.Stdout, 1<<20)
defer out.Flush()
t := in.NextInt()
for ; t > 0; t-- {
n := in.NextInt()
x := make([]int, n+1)
seen := make([]bool, n+1)
pos1, posN := -1, -1
for i := 1; i <= n; i++ {
x[i] = in.NextInt()
seen[x[i]] = true
if x[i] == 1 {
pos1 = i
}
if x[i] == n {
posN = i
}
}
missing := -1
for v := 1; v <= n; v++ {
if !seen[v] {
missing = v
break
}
}
if missing != -1 {
other := 1
if other == missing {
other = 2
}
fmt.Fprintf(out, "? %d %d\n", missing, other)
out.Flush()
ans := in.NextInt()
if ans == -1 {
return
}
if ans == 0 {
fmt.Fprintln(out, "! A")
} else {
fmt.Fprintln(out, "! B")
}
out.Flush()
} else {
fmt.Fprintf(out, "? %d %d\n", pos1, posN)
out.Flush()
d1 := in.NextInt()
if d1 == -1 {
return
}
fmt.Fprintf(out, "? %d %d\n", posN, pos1)
out.Flush()
d2 := in.NextInt()
if d2 == -1 {
return
}
if d1 < n-1 || d2 < n-1 {
fmt.Fprintln(out, "! A")
} else {
fmt.Fprintln(out, "! B")
}
out.Flush()
}
}
}