#include "bits/stdc++.h" using namespace std; using i64 = long long; #define body(x) ((x) >> 6) #define head(x) ((x) & 63) signed main(){ int n, x; cin >> n >> x; vector v(n); int i, j, k, left, right; for(auto& w : v) cin >> w; vector r(n + 1, 0); for(i = 0; i < n; ++i) r[i + 1] = r[i] + v[i]; array nex, prev; for(i = 0; i < n; ++i){ auto it = upper_bound(r.begin(), r.end(), r[i] + x); int idx = distance(r.begin(), it); nex[i] = min(idx, n); auto it2 = lower_bound(r.begin(), r.end(), r[i + 1] - x); idx = distance(r.begin(), it2); prev[i] = max(0, idx - 1); } array a; for(k = 1; k < n; ++k) for(i = 0, j = k; j < n; ++i, ++j){ bool f = false; for(right = max(i, prev[j]); right < j; ++right) if(!(a[body(right * 5000 + j)] & (1LL << head(right * 5000 + j)))){ f = true; break; } int left_bound = min(nex[i], j + 1); if(!f) for(left = i + 1; left < left_bound; ++left) if(!(a[body(left * 5000 + j)] & (1LL << head(left * 5000 + j)))){ f = true; break; } a[body(i * 5000 + j)] |= i64(f) << head(i * 5000 + j); } cout << (a[body(n - 1)] & (1L << head(n - 1)) ? "A" : "B") << endl; }