#include using namespace std; #define int long long #define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define all(x) (x).begin(),(x).end() #define sz(x) ((int)x.size()) templatebool chmax(T &a,T b){if(abool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;} /* */ using vi = vector; using vvi = vector; using P = pair; template class BinaryIndexedTree { public: int n; vector bit; BinaryIndexedTree():n(-1){} BinaryIndexedTree(int n_, T d):n(n_),bit(n_+1,d){} T sum(int i) { T s = 0; while(i > 0){ s += bit[i]; i -= i&-i; } return s; } void add(int i, T x) { if(i == 0) return; while(i <= n){ bit[i] += x; i += i&-i; } } T sum0(int i) { return sum(i+1); } void add0(int i, T x) { add(i+1, x); } T query(int l, int r) { return sum(r-1)-sum(l-1); } T query0(int l, int r) { return sum(r)-sum(l); } }; signed main() { int n, x; cin >> n >> x; vi a(n); rep(i, 0, n) cin >> a[i]; vi lr(n+1), rl(n+1); int r = 0, sum = 0; rep(l, 0, n){ while(r < n and sum + a[r] <= x){ sum += a[r]; r++; rl[r] = l; } lr[l] = r; if(l == r) r++; else sum -= a[l]; } // rep(i, 0, n+1) cout << lr[i] << " "; // cout << endl; // rep(i, 0, n+1) cout << rl[i] << " "; // cout << endl; vector> bitl(n+1, BinaryIndexedTree(n+1, 0)); vector> bitr(n+1, BinaryIndexedTree(n+1, 0)); rep(len, 1, n+1){ rep(left, 0, n-len+1){ int right = left+len; bool lose = true; int s = max(left, rl[right]); if(bitl[left].query0(s, right)) lose = false; int t = min(right, lr[left]+1); if(bitr[right].query0(left, t)) lose = false; if(lose){ bitl[left].add0(right, 1); bitr[right].add0(left, 1); } } } if(bitl[0].query0(n, n+1)) cout << "B" << endl; else cout << "A" << endl; // rep(i, 0, n){ // rep(j, 1, n+1) { // cout << bitl[i].query0(j, j+1) << " "; // } // cout << endl; // } // rep(i, 0, n){ // rep(j, 1, n+1) { // cout << bitr[i].query0(j, j+1) << " "; // } // cout << endl; // } return 0; }