#include using namespace std; #define F first #define S second #define R cin>> #define Z class #define ll long long #define ln cout<<'\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeof((c).begin()) #define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rep(i,n) REP(i,0,n) #define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++) templatevoid pr(A a){cout<void pr(A a,B b){cout<void pr(A a,B b,C c){cout<void pr(A a,B b,C c,D d){cout<void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<=0&&x=0&&y P; int dp[2][2][5001][5001],m,a[5555]; int dfs(int l, int r, int t,int k,ll sum) { if(dp[t][k][l][r]!=-1) return dp[t][k][l][r]; if(l==r) return t^1; int s=t^1,z; if(k==0) { if(sum+a[l]<=m) { z=dfs(l+1,r,t,0,sum+a[l]); if(z==t) s=z; z=dfs(l+1,r,t^1,0,0); if(z==t) s=z; z=dfs(l+1,r,t^1,1,0); if(z==t) s=z; } } else { if(sum+a[r]<=m) { z=dfs(l,r-1,t,1,sum+a[r]); if(z==t) s=z; z=dfs(l,r-1,t^1,0,0); if(z==t) s=z; z=dfs(l,r-1,t^1,1,0); if(z==t) s=z; } } dp[t][k][l][r]=s; return s; } void Main() { ll n; cin >> n >> m; rep(i,n) cin >> a[i]; memset(dp,-1,sizeof(dp)); if(dfs(0,n-1,1,0,0)||dfs(0,n-1,1,1,0)) pr("A"); else pr("B"); } int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}