#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; void calc(vector& P, int b, int n, vector& S, vector& sum) { vector p(1 << n); for (int S = 0; S < (1 << n); S++) { p[S].second = S; for (int i = 0; i < n; i++) if (S & (1 << i)) p[S].first += P[b + i]; } sort(p.begin(), p.end()); for (int j = 0; j < (1 << n); j++) { S[j] = p[j].second; sum[j] = p[j].first; } } int main() { int N, x; cin >> N >> x; vector P(N); for (int i = 0; i < N; i++) cin >> P[i]; int n = N / 2, _n = N - n; vector S(1 << n), _S(1 << _n), sum(1 << n), _sum(1 << _n); calc(P, 0, n, S, sum); calc(P, n, _n, _S, _sum); vector< vector > w; int _j = (1 << _n) - 1; for (int j = 0; j < (1 << n); j++) { int y = x - sum[j]; while (_j >= 0 && _sum[_j] > y) _j--; for (int k = _j; k >= 0 && _sum[k] == y; k--) { vector v; for (int i = 0; i < n; i++) if (S[j] & (1 << i)) v.push_back(i); for (int i = 0; i < _n; i++) if (_S[k] & (1 << i)) v.push_back(n + i); w.push_back(v); } } sort(w.begin(), w.end()); for (int j = 0; j < w.size(); j++) { vector& v = w[j]; for (int k = 0; k < v.size(); k++) cout << v[k] + 1 << (k + 1 < v.size() ? ' ' : '\n'); } }