#include #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) for (int i = (a) - 1; i >= 0; i--) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) using namespace std; typedef long long ll; vector> bruteforce(vector P) { int n = P.size(); vector> res; rep (i, 1 << n) { ll total = 0; rep (j, n) { if (i & 1 << j) total += P[j]; } res.emplace_back(total, i); } sort(res.begin(), res.end()); return res; } template ostream &operator <<(ostream &os, const vector &v) { rep (i, v.size()) { if (i) os << " "; os << v[i]; } return os; } int main() { ll N, S; cin >> N >> S; vector P(N); rep (i, N) cin >> P[i]; int l = N / 2; int r = (N + 1) / 2; vector vl, vr; rep (i, N) { if (i < l) { vl.push_back(P[N - 1 - i]); } else { vr.push_back(P[N - 1 - i]); } } auto ul = bruteforce(vl); auto ur = bruteforce(vr); vector ans; rep (i, ul.size()) { int lb = lower_bound(ur.begin(), ur.end(), make_pair(S - ul[i].first, 0ll)) - ur.begin(); int ub = upper_bound(ur.begin(), ur.end(), make_pair(S - ul[i].first, (ll)1e18)) - ur.begin(); rep2 (j, lb, ub) { ans.push_back(ul[i].second + (ur[j].second << l)); } } sort(ans.begin(), ans.end()); reverse(ans.begin(), ans.end()); rep (i, ans.size()) { vector v; rep (j, N) { if (ans[i] & 1 << j) v.push_back(N - j); } reverse(v.begin(), v.end()); cout << v << endl; } return 0; }