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.*;

public class utkarsh {

    InputStream is;
    PrintWriter out;
    
    class pair{
        int T, D, P, I;
        pair(int t, int d, int p, int i){
            T = t;
            D = d;
            P = p;
            I = i;
        }
    }
    class pr{
        int F, S;
        pr(int u, int v){
            F = u;
            S = v;
        }
    }
    
    void solve(){
        //Enter code here utkarsh
        int i, j, n, z;
        z = 10000;
        n = ni();
        pair[] a = new pair[n+1];
        for(i = 1; i <= n; i++)  a[i] = new pair(ni(), ni(), ni(), i);
        Arrays.sort(a, 1, n+1, (pair u, pair v) -> ((u.D != v.D) ? (u.D - v.D) : ((u.T != v.T) ? (u.T - v.T) : (u.P - v.P))));
        pr d[][] = new pr[n+1][z];
        for(i = 0; i < z; i++)  d[0][i] = new pr(0, -1);
        for(i = 1; i <= n; i++){
            for(j = 0; j < z; j++){
                if(j < a[i].T){
                    d[i][j] = new pr(d[i-1][j].F, 0);
                }else if(j >= a[i].D){
                    if(d[i-1][j].F > d[i][j-1].F)   d[i][j] = new pr(d[i-1][j].F, 0);
                    else        d[i][j] = new pr(d[i][j-1].F, 1);
                }else{
                    if((d[i-1][j - a[i].T].F + a[i].P) > d[i-1][j].F) d[i][j] = new pr((d[i-1][j - a[i].T].F + a[i].P), 2);
                    else    d[i][j] = new pr(d[i-1][j].F, 0);
                }
            }
        }
        i = n;
        j = z-1;
        int ans = 0;
        ArrayList<Integer> dp = new ArrayList<>();
        while(i > 0 && j > 0){
            if(d[i][j].S == 2){
                ans += a[i].P;
                dp.add(a[i].I);
                j -= a[i].T;
                i--;
            }else if(d[i][j].S == 0){
                i--;
            }else{
                j--;
            }
        }
        out.println(ans);
        out.println(dp.size());
        Collections.reverse(dp);
        for(int x : dp) out.print(x +" ");
        out.println();
    }
    
    long modpow(long base, long exp, long modulus) { base %= modulus; long result = 1L; while (exp > 0) { if ((exp & 1)==1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return result;
    }
    
    public static void main(String[] args) { new utkarsh().run();
    }
    void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush();
    }
    
    byte input[] = new byte[1024];
    int len = 0, ptr = 0;
    
    int readByte(){ if(ptr >= len){ ptr = 0; try{ len = is.read(input); }catch(IOException e){ throw new InputMismatchException(); } if(len <= 0){ return -1; } } return input[ptr++];
    }
    boolean isSpaceChar(int c){ return !( c >= 33 && c <= 126 ); 
    }
    int skip(){ int b = readByte(); while(b != -1 && isSpaceChar(b)){ b = readByte(); } return b;
    }
    
    char nc(){ return (char)skip();
    }
    String ns(){ int b = skip(); StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString();
    }
    int ni(){ int n = 0,b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } if(b == -1){ return -1; } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    long nl(){ long n = 0L; int b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    double nd(){ return Double.parseDouble(ns());
    }
    float nf(){ return Float.parseFloat(ns());
    }
    int[] na(int n){ int a[] = new int[n]; for(int i = 0; i < n; i++){ a[i] = ni(); } return a;
    }
    char[] ns(int n){ char c[] = new char[n]; int i,b = skip(); for(i = 0; i < n; i++){ if(isSpaceChar(b)){ break; } c[i] = (char)b; b = readByte(); } return i == n ? c : Arrays.copyOf(c,i);
    }
}