#include using namespace std; auto solve(int M) { vector P(M); for(int i = 0; i < M; ++i) cin >> P[i]; vector>> res; for(int bit = 0; bit < (1 << M); ++bit) { int cnt = 0; vector v; for(int i = 0; i < M; ++i) if(bit >> i & 1) { cnt += P[i]; v.push_back(i); } res.push_back(make_pair(cnt, v)); } return res; } int main() { int N, S; cin >> N >> S; auto P1 = solve(N / 2), P2 = solve(N - N / 2); sort(P2.begin(), P2.end()); vector> ans; for(auto [s1, v1] : P1) { auto it = lower_bound(P2.begin(), P2.end(), make_pair(S - s1, vector())); while(it != P2.end() and (*it).first == S - s1) { vector res = v1; for(auto x : (*it).second) res.push_back(x + N / 2); ans.push_back(res); advance(it, 1); } } sort(ans.begin(), ans.end()); for(auto v : ans) { for(auto x : v) cout << x + 1 << " "; cout << endl; } return 0; }