#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define range(a) a.begin(), a.end() int main() { int N; cin >> N; ll X; cin >> X; vector A(N); rep(i, N) cin >> A[i]; vector S(N + 1); rep(i, N) S[i + 1] = S[i] + A[i]; vector R(N + 1); repr(i, N) R[i] = R[i + 1] + A[i]; vector> dp(N, vector(N)); vector> eplr(N, vector(N)); vector> eprl(N, vector(N)); for (int d = 1; d <= N - 1; d++) { for (int l = 0; l + d <= N - 1; l++) { int r = l + d; // dpl[l][l+1]...dpl[l][l+x] -> 0 // dpr[r][r]...dpr[r][r-y] -> 0 int x = upper_bound(range(S), X + S[l]) - S.begin() - 1; int y = R.rend() - upper_bound(R.rbegin(), R.rend(), X + R[r + 1]) + 1; if (eprl[r][l] - eprl[r][x] + dp[r][x] != x - l + 1) { dp[l][r] = 1; } if (eplr[l][r] - eplr[l][y] + dp[l][y] != r - y + 1) { dp[l][r] = 1; } eplr[l][r] = dp[l][r] + eplr[l][r - 1]; eprl[r][l] = dp[l][r] + eprl[r][l + 1]; } } cout << (dp[0][N - 1] ? "A" : "B") << endl; }