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.io.*;
import java.util.*;
import java.lang.reflect.Array;

public class main864E {
    public static PrintWriter out = new PrintWriter(System.out);
    public static FastScanner enter = new FastScanner(System.in);

    public static void main(String[] args) throws IOException {
        solve();
        out.close();
    }

    static tuple[] arr;

    static  int dp[][];
    static pair goTo[][];
    static boolean take[][];
    static  boolean was[][];
    static int n;
    private static void solve() throws IOException {
        n = enter.nextInt();
        arr = new tuple[n];
        for (int i = 0; i < n; i++) {
            int a = enter.nextInt();
            int b = enter.nextInt();
            int c = enter.nextInt();
            tuple t = new tuple(a, b, c, i);
            arr[i]=t;
        }
        dp=new int[2001][n];
        was=new boolean[2001][n];
        take=new boolean[2001][n];
        goTo=new pair[2001][n];
        sortMergeNoRecursive(arr,0, arr.length, tuple.class, tuple::compareTo);
        mem(0,0);
        ArrayList<Integer> ll=new ArrayList<>();
        int x=0;
        int y=0;
        while(goTo[x][y]!=null){
            if(take[x][y]) ll.add(arr[y].ind);
            int a=goTo[x][y].x;
            int b=goTo[x][y].y;
            x=a;
            y=b;
        }
        if(take[x][y]) ll.add(arr[y].ind);
        out.println(dp[0][0]);
        out.println(ll.size());
        for (int i = 0; i <ll.size() ; i++) {
            out.print((ll.get(i)+1)+" ");
        }
    }

    private static void mem(int T, int pos) {
        if(was[T][pos]) return;
        if(pos==n-1){
            if(T+arr[n-1].t<arr[n-1].d){
                dp[T][pos]=arr[n-1].p;
                take[T][pos]=true;
            }
            was[T][pos]=true;
            return;
        }
        int max=0;
        mem(T,pos+1);
        int tmp=max;
        max=Math.max(max,dp[T][pos+1]);
        if(max>tmp)goTo[T][pos]= new pair(T, pos+1);
        if(T+arr[pos].t<arr[pos].d){
            mem(T+arr[pos].t, pos+1);
            tmp=max;
            max=Math.max(max, dp[T+arr[pos].t][pos+1]+arr[pos].p);
            if(max>tmp){
                goTo[T][pos]=new pair(T+arr[pos].t, pos+1);
                take[T][pos]=true;
            }
        }
        dp[T][pos]=max;
        was[T][pos]=true;
    }

    public static <T> void sortMergeNoRecursive(T[] arr, int first, int last, Class<T> c, Comparator<T> comparator) {
        int len = last;
        int n = 1;
        int shift;
        int two_size;
        T[] arr2;
        while (n < len) {
            shift = first;
            while (shift < len) {
                if (shift + n >= len) break;
                two_size = (shift + n * 2 > len) ? (len - (shift + n)) : n;
                arr2 = merge(Arrays.copyOfRange(arr, shift, shift + n),
                        Arrays.copyOfRange(arr, shift + n, shift + n + two_size), c, comparator);
                for (int i = 0; i < n + two_size; ++i)
                    arr[shift + i] = arr2[i];
                shift += n * 2;
            }
            n *= 2;
        }
    }

    public static <T> T[] merge(T[] arr_1, T[] arr_2, Class<T> c, Comparator<T> comparator) {
        int len_1 = arr_1.length, len_2 = arr_2.length;
        int a = 0, b = 0, len = len_1 + len_2;
        //T[] result = new <>[len];
        T[] result = (T[]) Array.newInstance(c, len);


        for (int i = 0; i < len; i++) {
            if (b < len_2 && a < len_1) {
                if (comparator.compare(arr_1[a], arr_2[b]) > 0) result[i] = arr_2[b++];
                else result[i] = arr_1[a++];
            } else if (b < len_2) {
                result[i] = arr_2[b++];
            } else {
                result[i] = arr_1[a++];
            }
        }
        return result;
    }

    static class pair{
        int x;
        int y;

        public pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    static class tuple implements Comparable<tuple> {
        int d, t, p, ind;

        public tuple(int t, int d, int p, int ind) {
            this.d = d;
            this.t = t;
            this.p = p;
            this.ind = ind;
        }

        @Override
        public int compareTo(tuple o) {
            return Integer.compare(d, o.d);
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return null;
                }
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        char nextChar() throws IOException {
            return (char) (br.read());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }
    }
}