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 CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")
using namespace std;
void prn(pair<int, int> x) { cout << x.first << " " << x.second << endl; }
void inn(long long int &ix) { scanf("%lld", &ix); }
void inn(long long int &ix, long long int &iy) { scanf("%lld%lld", &ix, &iy); }
void inn(int &ix) { scanf("%d", &ix); }
void inn(int &ix, int &iy) { scanf("%d%d", &ix, &iy); }
void inn(long double &ix) { scanf("%Lf", &ix); }
void outt(long long int ix) { printf("%lld", ix); }
void outt(long long int ix, char cx) { printf("%lld%c", ix, cx); }
void outt(int ix) { printf("%d", ix); }
void outt(int ix, char cx) { printf("%d%c", ix, cx); }
void outt(long double ix, char cx) { printf("%.12Lf%c", ix, cx); }
void outt(long double ix) { printf("%.12Lf", ix); }
void outt(pair<int, int> x) {
  cout << '{' << x.first << ',' << x.second << '}' << endl;
}
const int MM = 1200000;
int m, n, k, p1, p2, p3, f, a[MM], st[MM];
int dp[110][2120];
map<pair<int, int>, pair<int, int> > pre;
struct event {
  int tim, dead, val, idx;
};
event even[120];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> even[i].tim >> even[i].dead >> even[i].val;
    even[i].idx = i;
  }
  sort(even + 1, even + 1 + n,
       [=](event e1, event e2) { return e1.dead < e2.dead; });
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 2000; j++) {
      dp[i][j] = MM;
    }
  }
  for (int ind = 0; ind <= n; ind++) {
    for (int totVal = 0; totVal <= 2000; totVal++) {
      if (ind == 0) {
        if (totVal == 0) {
          dp[ind][totVal] = 0;
        } else {
          dp[ind][totVal] = MM;
        }
        continue;
      }
      if (totVal >= even[ind].val &&
          even[ind].dead >
              even[ind].tim + dp[ind - 1][totVal - even[ind].val]) {
        dp[ind][totVal] = dp[ind - 1][totVal - even[ind].val] + even[ind].tim;
        pre[{ind, totVal}] = {ind - 1, totVal - even[ind].val};
      }
      if (dp[ind][totVal] > dp[ind - 1][totVal]) {
        dp[ind][totVal] = dp[ind - 1][totVal];
        pre[{ind, totVal}] = {ind - 1, totVal};
      }
    }
  }
  pair<int, int> fin;
  for (int val = 2000; val >= 0; val--) {
    if (dp[n][val] < MM) {
      fin = {n, val};
      break;
    }
  }
  cout << fin.second << endl;
  pair<int, int> now, nex;
  vector<int> ans;
  while (fin != make_pair(0, 0)) {
    now = fin;
    nex = pre[fin];
    if (now.second > nex.second) {
      ans.push_back(now.first);
    }
    fin = nex;
  }
  cout << ans.size() << endl;
  while (ans.size()) {
    cout << even[ans.back()].idx << " ";
    ans.pop_back();
  }
  return 0;
}