#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; ll N, S, p; vector P; map > dp[35]; vector< vector > ret; bool operator<(const vector& a, const vector& b){ int i = 0; while(i b[i]) return false; } return a.size() < b.size(); } void dfs(ll val, int idx, vector v){ if(val == 0){ sort(ALLOF(v)); ret.push_back(v); return; } vector w = dp[idx][val]; rep(i,w.size()){ if(w[i] == -1){ dfs(val, idx-1, v); }else{ vector vv = v; vv.push_back(w[i]+1); dfs(val-P[w[i]], idx-1, vv); } } } int main(){ ios::sync_with_stdio(false); cin >> N >> S; rep(i,N){ cin >> p; P.push_back(p); } dp[0][0].push_back(-1); rep(i,N){ FOR(it,dp[i]){ dp[i+1][it->first].push_back(-1); dp[i+1][it->first + P[i]].push_back(i); } } dfs(S, N, vector()); sort(ALLOF(ret)); rep(i,ret.size()){ rep(j,ret[i].size()){ if(j!=0) cout << " "; cout << ret[i][j]; } cout << endl; } return 0; }