#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,S; cin >> N >> S; vector P(N); rep(i,N) cin >> P[i]; vector> dp(N + 1, vector(S + 1, 0)); dp[N][S] = 1; for(int i = N - 1; i >= 0; i--) { for(int s = 0; s <= S; s++) { if(0 <= s - P[i]) dp[i][s - P[i]] |= dp[i + 1][s]; dp[i][s] |= dp[i + 1][s]; } } function)> dfs = [&](int i, int sum, vector ans) -> void { if(i == N) { rep(j,(int)ans.size()) cout << ans[j] << " \n"[j == int(ans.size()) - 1]; } else { if(sum + P[i] <= S && dp[i + 1][sum + P[i]]) { ans.push_back(i + 1); dfs(i + 1, sum + P[i], ans); ans.pop_back(); } if(dp[i + 1][sum]) { dfs(i + 1, sum, ans); } } }; dfs(0, 0, {}); }