import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class Main { public static class Item implements Comparable { long cost; int index; public Item(long cost, int index) { super(); this.cost = cost; this.index = index; } @Override public int compareTo(Item o) { if(Long.compare(o.cost, this.cost) != 0){ return Long.compare(o.cost, this.cost); }else{ return Integer.compare(this.index, o.index); } } } public static void dfs(final long S, final int N, final int deep, Item[] items, long[] maximum, LinkedList stack, TreeSet answers){ if(S == 0){ StringBuilder sb = new StringBuilder(); boolean first = true; for(final int item : new TreeSet(stack)){ if(first){ first = false; }else{ sb.append(" "); } sb.append(item + 1); } answers.add(sb.toString()); return; }else if(deep >= N){ return; }else if(maximum[deep] < S){ return; } if(S >= items[deep].cost){ stack.addLast(items[deep].index); dfs(S - items[deep].cost, N, deep + 1, items, maximum, stack, answers); stack.removeLast(); } dfs(S, N, deep + 1, items, maximum, stack, answers); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final long S = sc.nextLong(); Item[] items = new Item[N]; for(int i = 0; i < N; i++){ items[i] = new Item(sc.nextLong(), i); } Arrays.sort(items); long[] maximum = new long[N]; for(int i = N - 1; i >= 0; i--){ maximum[i] = items[i].cost + (i == N - 1 ? 0 : maximum[i + 1]); } TreeSet answers = new TreeSet(); dfs(S, N, 0, items, maximum, new LinkedList(), answers); for(final String ans : answers){ System.out.println(ans); } } }