#include #include #include #include #include #define N_MAX 31 #define S_MAX 310000000 #define P_MAX 10000000 using namespace std; int main() { int N, S, P[N_MAX]; vector ans; cin >> N >> S; for (int i = 0; i < N; ++i) cin >> P[i]; int bmax = (1 << N) - 1; for (int b = 0; b <= bmax; ++b) { int temp = S; for (int i = 0; i < N; ++i) { if (b & (1 << i)) temp -= P[i]; if (temp < 0) break; } if (!temp) ans.push_back(b); } for (auto it = ans.begin(); it != ans.end(); ++it) { bool f = false; for (int i = 0; i < N_MAX; ++i) { if ((*it)& (1 << i)) { if (f) cout << ' ' << i+1; else { cout << i+1; ++f; } } } cout << endl; } return 0; }