#include #include #include #include using namespace std; #define N_MAX 31 int N, S; int P[N_MAX]; int main() { scanf("%d%d", &N, &S); for (int i = 0; i < N; i++) scanf("%d", P + i); vector>> v; for (int i = 1; i < 1 << N / 2; i++) { int sum = 0; vector id; for (int j = 0; 1 << j <= i; j++) { if (i & 1 << j) { sum += P[j]; id.push_back(j + 1); } } v.emplace_back(sum, id); } map>> m; for (unsigned i = 1 << N / 2; i < 1u << N; i += 1 << N / 2) { int sum = 0; vector id; for (int j = N / 2; 1u << j <= i; j++) { if (i & 1u << j) { sum += P[j]; id.push_back(j + 1); } } m[sum].push_back(id); } vector> res; for (auto& p : v) { if (p.first == S) { res.push_back(p.second); continue; } for (auto& _ : m[S - p.first]) { auto tmp = p.second; for (auto& e : _) tmp.push_back(e); res.push_back(tmp); } } for (auto& _ : m[S]) res.push_back(_); sort(res.begin(), res.end()); for (auto& _ : res) { for (int i = 0; i < _.size(); i++) { printf("%d%c", _[i], i + 1 < _.size() ? ' ' : '\n'); } } return 0; }