import kotlin.math.min val MOD = 1_000_000_007 fun main() { val (N, X) = readInts() val A = readInts() val dpL = Array(N){IntArray(N - it + 1)} val dpR = Array(N){IntArray(it + 2)} val mxR = run { val res = IntArray(N) var sum = 0L var r = N - 1 for (l in N - 1 downTo 0) { sum += A[l] while (r > l && sum > X) { sum -= A[r] r-- } res[l] = r - l + 1 } res } debug(mxR) val mxL = run { val res = IntArray(N) var sum = 0L var l = 0 for (r in 0 until N) { sum += A[r] while (l < r && sum > X) { sum -= A[l] l++ } res[r] = r - l + 1 } res } debug(mxL) for (d in 1 until N) { for (l in 0 until N - d) { val r = l + d val llen = min(d, mxL[r]) val lwin = dpL[l][d] - dpL[l][d-llen] < llen val rlen = min(d, mxR[l]) val rwin = dpR[r][d] - dpR[r][d-rlen] < rlen val win = if (lwin or rwin) 1 else 0 // debug{"$l $r $win"} dpL[l][d+1] = dpL[l][d] + win dpR[r][d+1] = dpR[r][d] + win } } debugDim(dpL) debugDim(dpR) val awin = dpL[0][N] - dpL[0][N - 1] == 1 if (awin) println("A") else println("B") } private val isDebug = try { // なんか本番でエラーでる System.getenv("MY_DEBUG") != null } catch (t: Throwable) { false } private fun readLn() = readLine()!! private fun readStrings() = readLn().split(" ") private fun readInts() = readStrings().map { it.toInt() }.toIntArray() private fun readLongs() = readStrings().map { it.toLong() }.toLongArray() private inline fun debug(msg: () -> String) { if (isDebug) System.err.println(msg()) } private fun debug(a: LongArray) { debug{a.joinToString(" ")} } private fun debug(a: IntArray) { debug{a.joinToString(" ")} } private fun debug(a: BooleanArray) { debug{a.map{if(it) 1 else 0}.joinToString("")} } private fun debugDim(A: Array) { if (isDebug) { for (a in A) { debug(a) } } }