import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.List; 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 class Seq implements Comparable { List seq; public Seq(List seq){ this.seq = new ArrayList(new TreeSet(seq)); //System.out.println(seq); } @Override public int compareTo(Seq arg0){ final int min_size = Math.min(this.seq.size(), arg0.seq.size()); final int max_size = Math.max(this.seq.size(), arg0.seq.size()); for(int i = 0; i < min_size; i++){ if(Integer.compare(this.seq.get(i), arg0.seq.get(i)) != 0){ return Integer.compare(this.seq.get(i), arg0.seq.get(i)); } } if(min_size == max_size){ return 0; }else if(min_size == this.seq.size()){ return -1; }else{ return 1; } } @Override public String toString(){ StringBuilder sb = new StringBuilder(); boolean first = true; for(final int item : this.seq){ if(first){ first = false; }else{ sb.append(" "); } sb.append(item + 1); } return sb.toString(); } } public static void dfs(final long S, final int N, final int deep, Item[] items, long[] maximum, LinkedList stack, TreeSet answers){ if(S == 0){ answers.add(new Seq(stack)); 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]); } //System.out.println(Arrays.toString(maximum) + " " + items[0].cost); TreeSet answers = new TreeSet(); dfs(S, N, 0, items, maximum, new LinkedList(), answers); for(final Seq ans : answers){ System.out.println(ans); } } }