package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func Scanner() string { sc.Scan() return sc.Text() } func main() { buf := make([]byte, 0) sc.Buffer(buf, 100000007) sc.Split(bufio.ScanWords) n, _ := strconv.Atoi(Scanner()) x, _ := strconv.Atoi(Scanner()) a := make([]int, n) for i := 0; i < n; i++ { a[i], _ = strconv.Atoi(Scanner()) } l := make([]int, n) r := make([]int, n) sum := 0 count := 0 for i := 0; i < n; i++ { for j := i; j < n; j++ { sum += a[j] if sum > x { break } count++ } l[i] = count sum = 0 count = 0 for j := i; j < n; j++ { sum += a[j] if sum > x { break } count++ } r[i] = count } dp_l := make([][]int, n+1) for i := 0; i < n; i++ { dp_l[i] = make([]int, n+1) } dp_r := make([][]int, n+1) for i := 0; i < n; i++ { dp_r[i] = make([]int, n+1) } left := 0 right := 0 for i := 0; i <= n; i++ { for j := 0; j < n; j++ { if i == 0 { dp_l[j][i] = 0 dp_r[j][i] = 0 continue } left = j right = j + i - 1 if right >= n { break } count = min(l[left], i-1) p := dp_r[right][i-1] - dp_r[right][i-count-1] if p != count { dp_l[left][i] = dp_l[left][i-1] + 1 dp_r[right][i] = dp_r[right][i-1] + 1 continue } count = min(r[right], i-1) p = dp_l[left][i-1] - dp_l[left][i-count-1] if p != count { dp_l[left][i] = dp_l[left][i-1] + 1 dp_r[right][i] = dp_r[right][i-1] + 1 continue } dp_l[left][i] = dp_l[left][i-1] dp_r[right][i] = dp_r[right][i-1] } } ans := "A" if dp_l[0][n] == dp_r[0][n-1] { ans = "B" } fmt.Println(ans) } func min(x int, y int) int { if x >= y { return y } else { return x } }