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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class E {
	static long price[], time[], save[], memo[][];
	static int N;
	static TreeMap<Integer, Integer> map;
	static pair[] a;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		price = new long[N];
		time = new long[N];
		save = new long[N];
		memo = new long[N + 1][2000 + 11];
		map = new TreeMap<>();
		a = new pair[N];
		for (int i = 0; i < N + 1; i++)
			Arrays.fill(memo[i], -1);
		for (int i = 0; i < N; i++) {
			time[i] = sc.nextLong();
			save[i] = sc.nextLong();
			price[i] = sc.nextLong();
			a[i] = new pair(save[i], time[i], price[i], i);
		}
		Arrays.sort(a);
		sol = new ArrayList<>();

		long ans = dp(0, 0);
		print(0, 0);

		System.out.println(ans);
		System.out.println(sol.size());

		for (int i = 0; i < sol.size(); i++) {
			if (i != sol.size())
				System.out.print(sol.get(i) + 1 + " ");
			else
				System.out.println(sol.get(i) + 1 + " ");

		}
	}

	static long dp(int i, int t) {
		if (i >= N)
			return 0;
		if (t >= 2000 + 11)
			return 0;
		if (memo[i][t] != -1)
			return memo[i][t];
		long leave = dp(i + 1, t);
		long take = 0;
		pair p = a[i];
		long tt = p.y;
		long ss = p.x;
		long pp = p.z;
		if (t + tt < ss)
			take = pp + dp(i + 1, (int) (t + tt));

		return memo[i][t] = Math.max(take, leave);

	}

	static ArrayList<Integer> sol;

	static void print(int item, int remW) {
		if (item == N)
			return; // we have finished !

		// 1. Get the solution of the current state
		long optimal = dp(item, remW);

		// 2. Check which transition was taken to get the optimal
		if (dp(item + 1, remW) == optimal) {
			// don't add the current item to solution because optimal leaves it
			// go to next state and print it
			print(item + 1, remW);
		} else {
			// add current item to solution because optimal takes it
			sol.add((int) a[item].i);
			// go to next state and print it
			print(item + 1, (int) (remW + a[item].y));
		}
	}

	static class pair implements Comparable<pair> {

		long x, y, z, i;

		public pair(long save, long time, long price, int i) {

			x = save;

			y = time;
			z = price;
			this.i = i;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			if (x != o.x)
				return x > o.x ? 1 : -1;
			if (y != o.y)
				return y > o.y ? 1 : -1;
			if (z != o.z)
				return z > o.z ? 1 : -1;

			return 0;
		}

	}

	static class Scanner {

		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System) {
			br = new BufferedReader(new InputStreamReader(System));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() {
			for (long i = 0; i < 3e9; i++)
				;
		}

	}
}