#include using namespace std; using i64 = long long; template struct BIT{ vector elm; BIT(int n, T init = T()) : elm(n + 1, init){ } // [0, x) T sum(int x){ T val = 0; for(; x > 0; x -= x & -x) val += elm[x]; return val; } // [l, r) T sum(int l, int r){ return sum(r) - sum(l); } void add(int x, T val){ for(++x; x < elm.size(); x += x & -x) elm[x] += val; } }; signed main(){ int n, x; cin >> n >> x; vector v(n); for(auto& w : v) cin >> w; vector r(n + 1, 0); for(int i = 0; i < n; ++i) r[i + 1] = r[i] + v[i]; vector nex(n, n), prev(n + 1, n); for(int i = 0; i < n; ++i){ auto it = upper_bound(r.begin(), r.end(), r[i + 1] + x); int idx = distance(r.begin(), it); nex[i] = idx - 1; prev[idx - 1] = min(prev[idx - 1], i); } for(int i = n; i > 0; --i) prev[i - 1] = min(prev[i - 1], prev[i]); vector> a(n, BIT(n)), b(n, BIT(n)); for(int k = 1; k < n; ++k) for(int i = 0, j = k; j < n; ++i, ++j){ bool f = false; // dp[i][j] : dp[i][j - x, j) int pj = max(i, prev[j]); int ni = min(nex[i], j + 1); f |= (a[i].sum(pj, j) != (j - pj)); f |= (b[j].sum(i + 1, ni) != (ni - (i + 1))); if(f){ a[i].add(j, 1); b[j].add(i, 1); } } /* for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j) cout << a[i].sum(j, j + 1) << " \n"[j == n - 1]; } cout << endl; */ cout << (a[0].sum(n - 1, n) ? "A" : "B") << endl; }