#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 nex(n, n), prev(n, 0); for(int i = 0; i < n; ++i){ int s_l = v[i]; int j = i + 1; for(; j < n; ++j){ s_l += v[j]; if(s_l > x) break; } nex[i] = min(j + 1, n); int s_r = v[i]; j = i - 1; for(; j >= 0; --j){ s_r += v[j]; if(s_r > x) break; } prev[i] = max(0, j); } 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; }