Problem: Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take ti seconds to save i-th item. In addition, for each item, he estimated the value of di — the moment after which the item i will be completely burned and will no longer be valuable for him at all. In particular, if ti ≥ di, then i-th item cannot be saved.

Given the values pi for each of the items, find a set of items that Polycarp can save such that the total value of this items is maximum possible. Polycarp saves the items one after another. For example, if he takes item a first, and then item b, then the item a will be saved in ta seconds, and the item b — in ta + tb seconds after fire started.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of items in Polycarp's house.

Each of the following n lines contains three integers ti, di, pi (1 ≤ ti ≤ 20, 1 ≤ di ≤ 2 000, 1 ≤ pi ≤ 20) — the time needed to save the item i, the time after which the item i will burn completely and the value of item i.

Output

In the first line print the maximum possible total value of the set of saved items. In the second line print one integer m — the number of items in the desired set. In the third line print m distinct integers — numbers of the saved items in the order Polycarp saves them. Items are 1-indexed in the same order in which they appear in the input. If there are several answers, print any of them.

Examples

Input

3
3 7 4
2 6 5
3 7 6


Output

11
2
2 3 


Input

2
5 6 1
3 3 5


Output

1
1
1 

Note

In the first example Polycarp will have time to save any two items, but in order to maximize the total value of the saved items, he must save the second and the third item. For example, he can firstly save the third item in 3 seconds, and then save the second item in another 2 seconds. Thus, the total value of the saved items will be 6 + 5 = 11.

In the second example Polycarp can save only the first item, since even if he immediately starts saving the second item, he can save it in 3 seconds, but this item will already be completely burned by this time.

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
public class EdB {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[0];
	public static MyScanner sc;
    public static PrintWriter out;
	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		PrintWriter out = new PrintWriter(System.out);
 		int n = sc.nextInt();
 		ArrayList<Fire> fires = new ArrayList<Fire>();
 		for(int j = 0;j<n;j++){
 			int takeTime = sc.nextInt();
 			int burnTime = sc.nextInt();
 			int value = sc.nextInt();
 			fires.add(new Fire(takeTime, burnTime, value, j+1));
 			
 		}
 		Collections.sort(fires);
 		int[][] dp = new int[n+1][2001];
 		for(int i = 1;i<=n;i++){
 			for(int j = 0;j<=2000;j++){
 				if (j >= fires.get(i-1).takeTime && j < fires.get(i-1).burnTime)
 					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-fires.get(i-1).takeTime]+fires.get(i-1).value);
 				dp[i][j] = Math.max(dp[i][j],  dp[i-1][j]);
 			}
 		}
 		int ans = 0;
 		int maxindex =0 ;
 		for(int time = 0;time<2000;time++){
 			if (dp[n][time] > ans){
 				ans = dp[n][time];
 				maxindex = time;
 			}
 		}
 		ArrayList<Integer> backtrack = new ArrayList<Integer>();
 		int currtime = maxindex;
 		int currindex = n;
 		long currans = ans;
 		while(currindex > 0){
 			if (currtime >= fires.get(currindex-1).takeTime && dp[currindex-1][currtime] < dp[currindex-1][currtime-fires.get(currindex-1).takeTime]+fires.get(currindex-1).value){
 				backtrack.add(fires.get(currindex-1).index);
 				currans-=fires.get(currindex-1).value;
 				currtime-=fires.get(currindex-1).takeTime;
 			}
 			currindex--;
 		}
 		Collections.reverse(backtrack);
 		
 		
 		out.println(ans);
 		out.println(backtrack.size());
 		for(int j : backtrack){
 			out.print(j + " ");
 		}
 		out.println();
 		out.close();	
 	}
	static class Fire implements Comparable<Fire>{
		private int takeTime;
		private int burnTime;
		private int value;
		private int index;
		public Fire(int takeTime, int burnTime, int value, int index){
			this.takeTime = takeTime;
			this.burnTime = burnTime;
			this.value = value;
			this.index = index;
		}
		public int compareTo(Fire other){
			return Integer.compare(burnTime,  other.burnTime);
		}
	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } 
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } 
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
    }	
}

//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is