#include #include #include using namespace std; typedef long long ll; typedef pair P; typedef pair P1; typedef pair P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define sc second #define rep(i,x) for(int i=0;i0;s-=s&-s) res+=bit[s]; return res; } }bitL[5005],bitR[5005]; bool dp[5005][5005]; int goL[5005],goR[5005]; int main(){ scanf("%d%d",&n,&x); repn(i,n) scanf("%d",&a[i]); repn(i,n){ goL[i] = n; ll sum = 0; for(int j=i;j<=n;j++){ sum += a[j]; if(sum > x){ goL[i] = j-1; break; } } goR[i] = 1; sum = 0; for(int j=i;j>=0;j--){ sum += a[j]; if(sum > x){ goR[i] = j+1; break; } } } for(int len=1;len<=n;len++){ for(int i=1;i+len-1<=n;i++){ int L = i, R = i+len-1; int x = min(goL[L],R-1); if(L <= x){ if(bitR[R].sum(x+1) > bitR[R].sum(L)){ dp[L][R] = 1; goto nxt; } } x = max(goR[R],L+1); if(x <= R){ if(bitL[L].sum(R-1) > bitL[R].sum(x-2)){ dp[L][R] = 1; goto nxt; } } bitL[L].add(R,1); bitR[R].add(L,1); nxt:; } } puts(dp[1][n]?"A":"B"); }