#include "bits/stdc++.h" using namespace std; using i64 = long long; 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, 0); for(int 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); } /* for(auto& x : nex) cout << x << " "; cout << endl; for(auto& x : prev) cout << x << " "; cout << endl; */ vector> a(n, vector(n, 0)); for(int k = 1; k < n; ++k) for(int i = 0, j = k; j < n; ++i, ++j){ bool f = false; for(int right = max(i, prev[j]); right < j; ++right) if(!a[i][right]){ f = true; break; } int left_bound = min(nex[i], j + 1); if(!f) for(int left = i + 1; left < left_bound; ++left) if(!a[left][j]){ f = true; break; } a[i][j] = f; } cout << (a[0][n - 1] ? "A" : "B") << endl; }