#include using namespace std; constexpr int MAX_N = 31; int n, s; pair p[MAX_N]; int accumulation[MAX_N]; vector> ans; void dfs(int index, int money, vector &goods) { if(money == s) { vector tmp(goods); sort(begin(tmp), end(tmp)); ans.emplace_back(tmp); return; } if(index == n) return; const int next_money = money + p[index].first; if(next_money <= s) { goods.emplace_back(p[index].second); dfs(index + 1, next_money, goods); goods.pop_back(); } if(money + accumulation[index] >= s) dfs(index + 1, money, goods); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> n >> s; for(int i = 0; i < n; ++i) { int price; cin >> price; p[i] = make_pair(price, i + 1); } sort(p, p + n, greater>()); for(int i = n - 2; i >= 0; --i) { accumulation[i] = accumulation[i + 1] + p[i + 1].first; } ans.reserve(n * n); vector goods; dfs(0, 0, goods); sort(begin(ans), end(ans)); for(const auto &vec : ans) { for(int i = 0; i < vec.size(); ++i) { cout << vec[i] << (i + 1 == vec.size() ? '\n' : ' '); } } return EXIT_SUCCESS; }