#include int ri() { int n; scanf("%d", &n); return n; } struct SegTree { std::vector data; int n; SegTree (int n_) { for (n = 1; n < n_; n <<= 1); data.resize(n << 1); } void set(int i, int val) { for (data[i += n] = val; i >>= 1; ) data[i] = data[i << 1] + data[i << 1 | 1]; } int sum(int l, int r) { int res = 0; for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (r & 1) res += data[--r]; if (l & 1) res += data[l++]; } return res; } }; int main() { int n = ri(), x = ri(); int a[n]; for (auto &i : a) i = ri(); int64_t sum[n + 1]; sum[0] = 0; for (int i = 0; i < n; i++) sum[i + 1] = a[i] + sum[i]; int left[n + 1], right[n + 1]; for (int i = 0; i <= n; i++) { left[i] = std::lower_bound(sum, sum + n + 1, sum[i] - x) - sum; right[i] = std::upper_bound(sum, sum + n + 1, sum[i] + x) - sum - 1; } std::vector r0(n + 1, SegTree(n + 1)); std::vector r1(n + 1, SegTree(n + 1)); std::vector r2(n + 1, SegTree(n + 1)); std::vector r3(n + 1, SegTree(n + 1)); bool dp[n + 1][n + 1][2]; memset(dp, 0, sizeof(dp)); for (int i = 0; i <= n; i++) { dp[i][i][0] = true; r0[i].set(i, true); r1[i].set(i, true); dp[i][i][1] = false; } for (int i = 1; i <= n; i++) { for (int j = 0; j + i <= n; j++) { int k = j + i; dp[j][k][1] = true; // dp[j][k][?] // eat left -> dp[j + 1, right[j]][k] if (j < right[j] && r1[k].sum(j + 1, right[j] + 1) != right[j] - j) { dp[j][k][1] = false; } if (j < right[j] && r3[k].sum(j + 1, right[j] + 1)) { dp[j][k][0] = true; } // eat right -> dp[j][[left[k], k)] if (left[k] < k && r0[j].sum(left[k], k) != k - left[k]) { dp[j][k][1] = false; } if (left[k] < k && r2[j].sum(left[k], k)) { dp[j][k][0] = true; } r0[j].set(k, dp[j][k][0]); r1[k].set(j, dp[j][k][0]); r2[j].set(k, dp[j][k][1]); r3[k].set(j, dp[j][k][1]); } } /* for (int i = 0; i < n; i++) { for (int j = i + 1; j <= n; j++) { std::cerr << i << "," << j << " : " << dp[i][j][0] << "," << dp[i][j][1] << std::endl; } }*/ std::cout << (dp[0][n][0] ? "A" : "B") << std::endl; return 0; }