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, 5000) for i := 0; i < n; i++ { a[i], _ = strconv.Atoi(Scanner()) } l := make([]int, 5000) r := make([]int, 5000) sum := 0 b := 0 c := 0 for b != n { for c != n && sum+a[c] <= x { sum += a[c] c++ } l[b] = c - b sum -= a[b] b++ } b = n - 1 c = n - 1 sum = 0 for c >= 0 { for b != 0 && sum+a[b] <= x { sum += a[b] b-- } r[c] = c - b sum -= a[c] c-- } dp_l := make([][]int, 5000) for i := 0; i < n; i++ { dp_l[i] = make([]int, 5001) } dp_r := make([][]int, 5000) for i := 0; i < n; i++ { dp_r[i] = make([]int, 5001) } left := 0 right := 0 q := 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 } q = min(l[left], i-1) p := dp_r[right][i-1] - dp_r[right][i-q-1] if p != q { dp_l[left][i] = dp_l[left][i-1] + 1 dp_r[right][i] = dp_r[right][i-1] + 1 continue } q = min(r[right], i-1) p = dp_l[left][i-1] - dp_l[left][i-q-1] if p != q { 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 } }