#include <bits/stdc++.h>
using namespace std;
struct po {
  int t;
  int d;
  int p;
};
struct spas {
  int time;
  vector<int> s;
};
vector<pair<int, po>> arr;
map<int, spas> matr;
bool f(int a, int b) { return arr[a].second.d < arr[b].second.d; }
bool ff(pair<int, po> a, pair<int, po> b) { return a.second.d < b.second.d; }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    arr.push_back({i, {a, b, c}});
  }
  sort(arr.begin(), arr.end(), ff);
  matr[0].time = 0;
  for (int j = 1; j <= (20 * n); j++) {
    matr[j].time = -1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = (20 * n); j >= 0; j--) {
      if (matr[j].time != -1 &&
          matr[j].time + arr[i].second.t < arr[i].second.d) {
        int p = j + arr[i].second.p;
        vector<int> s = matr[j].s;
        int t = matr[j].time + arr[i].second.t;
        s.push_back(i);
        if (matr[p].time == -1 || t < matr[p].time) {
          matr[p].time = t;
          matr[p].s = s;
        }
      }
    }
  }
  int i;
  for (i = 20 * n; i >= 0; i--) {
    if (matr[i].time != -1) break;
  }
  cout << i << endl;
  vector<int> vec = matr[i].s;
  sort(vec.begin(), vec.end(), f);
  cout << vec.size() << endl;
  for (int i = 0; i < vec.size(); i++) {
    cout << arr[vec[i]].first + 1 << " ";
  }
  return 0;
}
