#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
struct node{
int t,d,p,tot;
}a[200];
int f[3000];
bool cmp(node x,node y){
return x.d<y.d;
}
bitset<150> ans[2050];
int cc[2050];
int main(){
int n;
scanf(“%d”,&n);
for (int i=1;i<=n;++i){
scanf(“%d%d%d”,&a[i].t,&a[i].d,&a[i].p);
a[i].tot=i;
}
sort(a+1,a+n+1,cmp);
for (int i=1;i<=n;++i)
for (int j=a[i].d-1;j>=a[i].t;–j)
if (f[j]<f[j-a[i].t]+a[i].p){
f[j]=f[j-a[i].t]+a[i].p;
ans[j]=ans[j-a[i].t];
ans[j].set(i);
}
int ma=0;
int num=0;
for (int i=a[n].d;i>=0;–i)
if (f[i]>ma){
ma=f[i];
num=i;
}
printf(“%d\n”,ma);
int T=0;
for (int i=1;i<=n;++i)
if (ans[num].test(i)){
++T;
cc[T]=a[i].tot;
}
printf(“%d\n”,T);
for (int i=1;i<=T;++i)
if (i==1) printf(“%d”,cc[i]);
else printf(” %d”,cc[i]);
printf(“\n”);
return 0;
}