#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; class BIT { private: ll N; vector node; public: BIT(ll M) { node = vector(M + 1, 0); N = M; } ll sum(ll i) { ll s = 0; while (i > 0) { s += node[i]; i -= i & -i; } return s; } ll sum(ll i, ll j) { ll l = sum(i - 1); ll r = sum(j); return r - l; } void add(ll i, ll x) { while (i <= N) { node[i] += x; i += i & -i; } } }; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N, X; scanf("%lld %lld", &N, &X); vector a(N); for (ll i = 0; i < N; i++) scanf("%lld", &a[i]); vector rb(N); vector lb(N); for (ll i = 0; i < N; i++) { ll j = i; ll sum = 0; while (j < N && sum + a[j] <= X) { rb[i] = j; sum += a[j]; j++; } } for (ll i = N - 1; i >= 0; i--) { ll j = i; ll sum = 0; while (j >= 0 && sum + a[j] <= X) { lb[i] = j; sum += a[j]; j--; } } vector vbl(N, BIT(N + 1)), vbr(N, BIT(N + 1)); for (ll len = 1; len <= N; len++) { for (ll left = 0; left + len - 1 < N; left++) { ll right = left + len - 1; ll lose = 1; //cout << right << endl; if (vbl[left].sum(max(left, lb[right]) + 1, right)) lose = 0; if (vbr[right].sum(left + 2, min(right, rb[left]) + 1)) lose = 0; if (lose) { vbl[left].add(right + 1, 1); vbr[right].add(left + 1, 1); } } } if (vbl[0].sum(N,N)) puts("B"); else puts("A"); return 0; }