#include #define rep(i,n) for (int i = 0; i < (n); ++i) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair; using VI = vector; using VVI = vector; int main() { int n; ll S; cin >> n >> S; int n1 = (n + 1) / 2, n2 = n / 2; vector p1(n1), p2(n2); rep(i, n1) cin >> p1[i]; rep(i, n2) cin >> p2[i]; set> cost_set; rep(s, 1 << n1) { ll tot = 0; rep(k, n1) { if (s >> k & 1) { tot += p1[k]; } } cost_set.emplace(tot, s); } vector ans; rep(s, 1 << n2) { ll tot = 0; rep(k, n2) { if (s >> k & 1) { tot += p2[k]; } } auto it = cost_set.lower_bound({S - tot, 0}); while(it != cost_set.end() && it->first == S - tot) { ll t = it->second | ll(s) << n1; ans.push_back(t); it++; } } sort(all(ans), [](ll x, ll y) { while(1) { if (x == 0 && x < y) return true; if (y == 0) return false; int bx = x & 1, by = y & 1; if (bx > by) return true; else if (bx < by) return false; x >>= 1; y >>= 1; } }); for(int s: ans) { int id = 1; while(s) { if (s & 1) { cout << id; if (s) cout << ' '; } s >>= 1; id++; } cout << endl; } }