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 javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.file.Paths;
import java.util.*;
public class Main extends PrintWriter {
    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
    Main () { super(System.out); }
    public static void main(String[] args) throws IOException{
        Main  d1=new Main   ();d1.main();d1.flush();
    }
    void main() throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        PrintWriter out = new PrintWriter(System.out);
        int t=1;
     //   t=i(s()[0]);
        while(t-->0) {
               String[] s1=s();
               int n=i(s1[0]);
               int[] a=new int[n];int[] b=new int[n];int[] c=new int[n];
           //    arri(a,n);arri(b,n);arri(c,n);
               Pair[] p=new Pair[n];
               for(int i=0;i<n;i++){String[ ]s2=s();
                   p[i]=new Pair(i(s2[0]),i(s2[1]),i(s2[2]),i+1);
               }
               Arrays.sort(p,new Comparator<Pair>(){
                   public int compare(Pair p1,Pair p2){
                       return p1.b-p2.b;
                   }
               });
               ArrayList<Integer>[] sb1=new ArrayList[2000];int ind=0;
               Arrays.fill(sb1,new ArrayList<>());
               int ans=0;int[] dp=new int[2000];int size=0;
               for(int i=0;i<n;i++){
//                   System.out.println(p[i].a+" "+p[i].b+" "+p[i].c);
                   for(int j=p[i].b-p[i].a-1;j>=0;j--){
                   //    System.out.println(dp[j]+" "+i+" "+j);
                      if(dp[j]+p[i].c>dp[j+p[i].a]){
                           sb1[j+p[i].a]=new ArrayList<>(sb1[j]);
                           sb1[j+p[i].a].add(p[i].d);
                      }
                       dp[j+p[i].a]=Math.max(dp[j+p[i].a],dp[j]+p[i].c);
                      if(dp[j+p[i].a]>ans){ind=j+p[i].a; size=sb1[j+p[i].a].size();}
                       ans=Math.max(ans,dp[j+p[i].a]);

                   }
               }sb.append(ans+"\n");
             sb.append(size+"\n");
             for(Integer j:sb1[ind]){
                 sb.append(j+" ");
             }sb.append("\n");
        }
        System.out.println(sb);

    } long[] st;//new long[4*n];

    long query(int i,int s,int e,int qs,int qe){
        if(qs>e||qe<s) return Integer.MIN_VALUE;
        if(s>=qs&&e<=qe) return st[i];
        int mid=(s+e)/2;
        long l=query(2*i,s,mid,qs,qe);
        long r=query(2*i+1,mid+1,e,qs,qe);
        return Math.max(l,r);
    }
    void pointupdate(int i,int s,int e,int qi,long  a){
        if(s==e){
            st[i]=a;return;
        }
        int mid=(s+e)/2;
        if(qi<=mid) pointupdate(2*i,s,mid,qi,a);
        else pointupdate(2*(i)+1,mid+1,e,qi,a);
        st[i]=Math.max(st[2*i],st[2*i+1]);
    }
    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
     static String[] s() throws IOException {
        return s.readLine().trim().split("\\s+");
    }
    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
    public void arr(long[] a,int n) throws IOException {
        //        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] s2=s();
        for(int i=0;i<n;i++){
            a[i]=l(s2[i]);
        }
    }
    public void arri(int[] a,int n) throws IOException{
        //        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] s2=s();
        for(int i=0;i<n;i++){
            a[i]=i(s2[i]);
        }
    }
    public void sort(int[] a,int l,int h){
        if(l==h) return;
        int mid=(l+h)/2;

        sort(a,l,mid);
        sort(a,mid+1,h);
        merge(a,l,(l+h)/2,h);
    }
    void merge(int arr[], int l, int m, int r) {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int[n1];
        int R[] = new int[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
}
class Pair {
    int a;
    int b,c,d;
    public Pair(int a,int b,int c,int d){
        this.a=a;this.b=b;this.c=c;this.d=d;
        }
}class Sortbyroll implements Comparator<Pair> {
    public int compare(Pair a, Pair b)
    {
      return a.b-b.b;

    }}