import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class Main { static int n; static long s; static long[] list; public static void main(String[] args) { try (Scanner scan = new Scanner(System.in)) { n = Integer.parseInt(scan.next()); s = Long.parseLong(scan.next()); list = new long[n]; for(int i=0; i indexList = new ArrayList(); ArrayList left = new ArrayList(); ArrayList right = new ArrayList(); ArrayList outList = new ArrayList(); solve(0, n/2, 0, left, indexList); solve(n/2, n, 0, right, indexList); Collections.sort(right); for(int i=0; i= 0) { if(now != right.get(m).v) break; outList.add((left.get(i).add(right.get(m)).toString())); } break; } else if(v > s) { r = m-1; } else if(v < s) { l = m+1; } } } Collections.sort(outList, new UserComparator()); for(String str : outList) { System.out.println(str); } } } static void solve(int i, int n, long sum, ArrayList nowList, ArrayList indexList) { if(i == n) { nowList.add(new Node(sum, (ArrayList)indexList.clone())); return; } solve(i+1, n, sum, nowList, indexList); indexList.add(i); solve(i+1, n, sum + list[i], nowList, indexList); indexList.remove(Integer.valueOf(i)); } static class Node implements Comparable{ long v; ArrayList indexes; Node(long v, ArrayList indexes) { this.v = v; this.indexes = indexes; } @Override public int compareTo(Node o) { return (int)(v - o.v); } public Node add(Node o) { ArrayList ret = new ArrayList(); ret.addAll(indexes); ret.addAll(o.indexes); return new Node(v, ret); } @Override public String toString() { StringBuffer sb = new StringBuffer(); for(int i=0; i0) sb.append(" "); sb.append(indexes.get(i)+1); } return sb.toString(); } } final static class UserComparator implements Comparator { public int compare(Object o1, Object o2) { String values1[] = ((String)o1).split(" "); String values2[] = ((String)o2).split(" "); int i=0; while(true) { long v1 = Long.parseLong(values1[i]); long v2 = Long.parseLong(values2[i]); if(v1 == v2) { i++; continue; } return (int)(v1 - v2); } } } }