#pragma comment (linker, "/STACK:256000000") #define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; typedef string::const_iterator State; #define eps 1e-11L #define MAX_MOD 1000000007LL #define GYAKU 500000004LL #define MOD 998244353LL #define seg_size 262144 #define pb push_back #define mp make_pair typedef long long ll; #define REP(a,b) for(long long (a) = 0;(a) < (b);++(a)) #define ALL(x) (x).begin(),(x).end() void init() { iostream::sync_with_stdio(false); cout << fixed << setprecision(100); } bool ans[5000][5000] = {}; bool visited[5000][5000] = {}; int next_go[2][5000 * 5000] = {}; int union_find(int now, bool dir) { if (next_go[dir][now] == now) return now; return next_go[dir][now] = union_find(next_go[dir][now], dir); } pair to_pair(int now) { return mp(now / 5000, now % 5000); } int to_int(pair now) { return now.first * 5000 + now.second; } ll summing[7000] = {}; ll calc_sum(int a, int b) { return summing[b+1] - summing[a]; } void solve() { ll n, x; cin >> n >> x; vector inputs; REP(i, n) { int a; cin >> a; inputs.pb(a); } for (int i = 0; i < inputs.size(); ++i) { summing[i + 1] += inputs[i] + summing[i]; } for (int i = inputs.size(); i + 1 < 7000; ++i) { summing[i + 1] = summing[i]; } REP(i, 5000) { REP(q, 5000) { next_go[0][i*5000+q] = next_go[1][i*5000+q] = i*5000+q; } } for (int i = 0; i < n; ++i) { for (int q = i; q >= 0; --q) { if (ans[i][q] == 1) continue; { //dir = 0 while (true) { int next = union_find(i * 5000 + q, 0); if (next/5000 == 0) break; if (calc_sum(next/5000 - 1, i - 1) > x) break; ans[next/5000 - 1][q] = 1; next_go[0][next] = next - 5000; } } { //dir = 1 while (true) { int next = union_find(i * 5000 + q, 1); if (next % 5000 == n-1) break; if (calc_sum(q+1, next % 5000 + 1) > x) break; ans[next / 5000][next % 5000 + 1] = 1; next_go[1][next] = next + 1; } } } } if (ans[0][n - 1] == 0) { cout << "B" << endl; } else { cout << "A" << endl; } return; } #undef int int main() { init(); solve(); }