#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) cout << lr[i] << " "; // cout << endl; // rep(i, 0, n) cout << rl[i] << " "; // cout << endl; vector> bitl(n+1, BinaryIndexedTree(n+1, 0)); vector> bitr(n+1, BinaryIndexedTree(n+1, 0)); rep(i, 0, n+1){ bitl[i].add0(i, 1); bitr[i].add0(i, 1); } rep(len, 1, n+1){ rep(left, 0, n-len+1){ int right = left+len; int s = min(lr[left], right); int t = max(left, rl[right]); if(((s-left) - bitr[r].query0(left+1, s+1)) or ((right-t) - bitl[left].query0(t, right))){ bitl[left].add0(right, 1); bitr[right].add0(left, 1); } } } if(bitl[0].query0(n, n+1)) cout << "A" << endl; else cout << "B" << endl; return 0; }