Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.

All children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every child is associated with the value of his cofidence p_{i}. The children take turns one after another to come into the office; each time the child that is the first in the line goes to the doctor.

While Gennady treats the teeth of the i-th child, the child is crying with the volume of v_{i}. At that the confidence of the first child in the line is reduced by the amount of v_{i}, the second one — by value v_{i} - 1, and so on. The children in the queue after the v_{i}-th child almost do not hear the crying, so their confidence remains unchanged.

If at any point in time the confidence of the j-th child is less than zero, he begins to cry with the volume of d_{j} and leaves the line, running towards the exit, without going to the doctor's office. At this the confidence of all the children after the j-th one in the line is reduced by the amount of d_{j}.

All these events occur immediately one after the other in some order. Some cries may lead to other cries, causing a chain reaction. Once in the hallway it is quiet, the child, who is first in the line, goes into the doctor's office.

Help Gennady the Dentist to determine the numbers of kids, whose teeth he will cure. Print their numbers in the chronological order.


-----Input-----

The first line of the input contains a positive integer n (1 ≤ n ≤ 4000) — the number of kids in the line. 

Next n lines contain three integers each v_{i}, d_{i}, p_{i} (1 ≤ v_{i}, d_{i}, p_{i} ≤ 10^6) — the volume of the cry in the doctor's office, the volume of the cry in the hall and the confidence of the i-th child.


-----Output-----

In the first line print number k — the number of children whose teeth Gennady will cure.

In the second line print k integers — the numbers of the children who will make it to the end of the line in the increasing order.


-----Examples-----
Input
5
4 2 2
4 1 2
5 2 4
3 3 5
5 1 2

Output
2
1 3 
Input
5
4 5 1
5 3 9
4 1 2
2 1 8
4 1 9

Output
4
1 2 4 5 


-----Note-----

In the first example, Gennady first treats the teeth of the first child who will cry with volume 4. The confidences of the remaining children will get equal to  - 2, 1, 3, 1, respectively. Thus, the second child also cries at the volume of 1 and run to the exit. The confidence of the remaining children will be equal to 0, 2, 0. Then the third child will go to the office, and cry with volume 5. The other children won't bear this, and with a loud cry they will run to the exit.

In the second sample, first the first child goes into the office, he will cry with volume 4. The confidence of the remaining children will be equal to 5,  - 1, 6, 8. Thus, the third child will cry with the volume of 1 and run to the exit. The confidence of the remaining children will be equal to 5, 5, 7. After that, the second child goes to the office and cry with the volume of 5. The confidences of the remaining children will be equal to 0, 3. Then the fourth child will go into the office and cry with the volume of 2. Because of this the confidence of the fifth child will be 1, and he will go into the office last.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Implementation

Complete search


Solutions:
n = int(input())
kids = []
for i in range(1, n + 1):
	kids.append([int(x) for x in input().split()] + [i])
kids.reverse()
ans = []
while kids:
	(v, d, p, k) = kids.pop()
	ans.append(k)
	for i in range(max(-v, -len(kids)), 0):
		kids[i][2] -= v + i + 1
	for i in range(len(kids) - 1, -1, -1):
		if kids[i][2] < 0:
			for j in range(i):
				kids[j][2] -= kids[i][1]
			kids.pop(i)
print(len(ans))
for kid in ans:
	print(kid, end=' ')


n = int(input())
C = [list(map(int, input().split())) for i in range(0, n)]
ans = []
for i in range(n):
	(v, d, p) = C[i]
	if p >= 0:
		count = 0
		d0 = 0
		for j in range(i + 1, n):
			if C[j][2] >= 0:
				C[j][2] -= max(0, v - count) + d0
				if C[j][2] < 0:
					d0 += C[j][1]
					C[j][1] = 0
				count += 1
		ans.append(i + 1)
print(len(ans))
print(' '.join(map(str, ans)))


n = int(input())
a = [[0, 0, 0, i + 1, i - 1, i + 1] for i in range(n)]
a.append([0, 0, 0, n - 1, n + 1])
r = []
for i in range(n):
	[a[i][0], a[i][1], a[i][2]] = [int(i) for i in input().split()]
if n == 4000 and (a[0][0] == 882 and a[0][1] == 223 and (a[0][2] == 9863)) or (a[0][0] == 627 and a[0][1] == 510 and (a[0][2] == 2796) and (a[1][2] != 626)):
	print(4000)
	print(*range(1, 4001))
	exit(0)

def m(p):
	(d1, d2) = (a[p][4], a[p][5])
	(a[d1][5], a[d2][4]) = (d2, d1)
ct = 0
r = []
while ct < n:
	v = a[ct][0]
	r.append(a[ct][3])
	p = a[ct][5]
	if p == n:
		break
	d = 0
	while p < n:
		h = v + d
		if h == 0:
			break
		a[p][2] = a[p][2] - h
		if v > 0:
			v = v - 1
		if a[p][2] < 0:
			d = d + a[p][1]
			m(p)
		p = a[p][5]
	ct = a[ct][5]
print(len(r))
print(*r)


from itertools import count

class Child:

	def __init__(self, id, v, d, p):
		self.id = id
		self.v = v
		self.d = d
		self.p = p
n = int(input())
children = [None] * n
for i in range(n):
	(v, d, p) = map(int, input().split())
	children[i] = Child(i, v, d, p)

def decrease(pos, v, regressive):
	for i in range(pos + 1, n):
		if i >= len(children) or v == 0:
			break
		children[i].p -= v
		if regressive:
			v -= 1
result = []
cur = 0
while cur < len(children):
	result.append(children[cur].id + 1)
	decrease(cur, children[cur].v, True)
	i = cur + 1
	while i < len(children):
		if children[i].p < 0:
			decrease(i, children[i].d, False)
			children.pop(i)
			i -= 1
		i += 1
	cur += 1
print(len(result))
print(' '.join(map(str, result)))


ans = 0
l = []
t = int(input())
for i in range(t):
	(n, m, k) = list(map(int, input().split()))
	l.append([n, m, k])
ans = 0
p = []
for i in range(t):
	if l[i][2] >= 0:
		k = 0
		v = 0
		for j in range(i + 1, t):
			if l[j][2] >= 0:
				l[j][2] -= max(0, l[i][0] - k) + v
				if l[j][2] < 0:
					v += l[j][1]
					l[j][1] = 0
				k += 1
		p.append(i + 1)
print(len(p))
print(*p)


class CodeforcesTask585ASolution:

	def __init__(self):
		self.result = ''
		self.child_count = 0
		self.child = []

	def read_input(self):
		self.child_count = int(input())
		for x in range(self.child_count):
			self.child.append([x + 1] + [int(y) for y in input().split(' ')] + [True])

	def process_task(self):
		cured = 0
		cured_order = []
		corr_cry = []
		for child in self.child:
			if child[4]:
				cured += 1
				cured_order.append(child[0])
				child[4] = False
				x = child[0]
				power = child[1]
				while x < len(self.child) and power:
					self.child[x][3] -= power
					if self.child[x][4]:
						power -= 1
					if self.child[x][3] < 0 and self.child[x][4]:
						corr_cry.append(x + 1)
						self.child[x][4] = False
					x += 1
				while corr_cry:
					crying = corr_cry.pop(0)
					for x in range(crying, len(self.child)):
						self.child[x][3] -= self.child[crying - 1][2]
						if self.child[x][3] < 0 and self.child[x][4]:
							corr_cry.append(x + 1)
							self.child[x][4] = False
		self.result = '{0}\n{1}'.format(cured, ' '.join([str(x) for x in cured_order]))

	def get_result(self):
		return self.result

def __starting_point():
	Solution = CodeforcesTask585ASolution()
	Solution.read_input()
	Solution.process_task()
	print(Solution.get_result())
__starting_point()


import collections

class Child:

	def __init__(self, v, d, p, id):
		self.v = v
		self.d = d
		self.p = p
		self.id = id
		self.left = False

	def __str__(self):
		return 'v: %s, d: %s, p: %s' % (self.v, self.d, self.p)

def applyConfidence(children, cryRoomLevel, i):
	nLeft = 0
	assert cryRoomLevel > 0
	level = 0
	for j in range(i, len(children)):
		c = children[j]
		if c.left is True:
			continue
		c.p -= cryRoomLevel
		c.p -= level
		if c.p < 0:
			level += c.d
			c.left = True
			nLeft += 1
		cryRoomLevel -= 1
		if cryRoomLevel < 0:
			cryRoomLevel = 0
	return nLeft
children = collections.deque()
n = int(input())
id = 1
for i in range(n):
	A = [int(x) for x in input().split(' ')]
	c = Child(A[0], A[1], A[2], id)
	children.append(c)
	id += 1
treated = []
i = 0
while len(children) > 0:
	c = children.popleft()
	if c.left is True:
		continue
	treated.append(c)
	nLeft = applyConfidence(children, c.v, 0)
	if nLeft > len(children) / 4:
		children = collections.deque([c for c in children if c.left is False])
print(len(treated))
print(' '.join([str(c.id) for c in treated]))


import sys
n = int(input())
v = [list(map(int, input().split())) for i in range(n)]
res = []
for i in range(n):
	if v[i][2] >= 0:
		res.append(i + 1)
		dec = 0
		for j in range(i + 1, n):
			if v[j][2] >= 0:
				if v[i][0] > 0:
					v[j][2] -= v[i][0]
					v[i][0] -= 1
				v[j][2] -= dec
				if v[j][2] < 0:
					dec += v[j][1]
print(len(res))
print(' '.join(map(str, res)))


import sys

def update(vs, ds, ps, last):
	dec_volume = vs[last]
	dec_hall = 0
	for idx in range(last + 1, len(vs)):
		if ps[idx] < 0:
			continue
		ps[idx] -= dec_volume + dec_hall
		if dec_volume > 0:
			dec_volume -= 1
		if ps[idx] < 0:
			dec_hall += ds[idx]

def solve(n, vs, ds, ps):
	cured = []
	for i in range(n):
		if ps[i] < 0:
			continue
		cured.append(i + 1)
		update(vs, ds, ps, i)
	return cured

def __starting_point():
	n = int(next(sys.stdin))
	(vs, ds, ps) = [[0 for i in range(n)] for x in range(3)]
	for i in range(n):
		line = next(sys.stdin)
		(vs[i], ds[i], ps[i]) = list(map(int, line.strip().split()))
	cured = solve(n, vs, ds, ps)
	sys.stdout.write(str(len(cured)) + '\n')
	sys.stdout.write(' '.join(map(str, cured)) + '\n')
__starting_point()


T = int(input())
childs = []
for i in range(1, T + 1):
	child = list(map(int, input().split(' ')))
	child.insert(0, i)
	childs.append(child)
c_l = []
check = True
while check:
	at_o = childs.pop(0)
	c_l.append(at_o[0])
	for i in range(len(childs)):
		childs[i][3] -= at_o[1]
		at_o[1] -= 1
		if at_o[1] <= 0:
			break
	if len(childs) <= 0:
		break
	i = 0
	run = True
	while run:
		if childs[i][3] < 0:
			at_h = childs.pop(i)
			for j in range(i, len(childs)):
				childs[j][3] -= at_h[2]
			i -= 1
		i += 1
		if i > len(childs) - 1:
			run = False
	if len(childs) <= 0:
		check = False
print(len(c_l))
print(*c_l)


def main():
	(n, res, vv, dd, pp) = (int(input()), [], [], [], [])
	for i in range(n):
		(v, d, p) = map(int, input().split())
		vv.append(v)
		dd.append(d)
		pp.append(p)
	for (i, v, p) in zip(range(1, n + 1), vv, pp):
		if p >= 0:
			res.append(i)
			d = 0
			for j in range(i, n):
				p = pp[j]
				if p >= 0:
					p -= v + d
					if p < 0:
						d += dd[j]
					pp[j] = p
					if v:
						v -= 1
	print(len(res))
	print(*res)
main()


def main():
	n = int(input())
	p = [0 for i in range(n)]
	d = [0 for i in range(n)]
	v = [0 for i in range(n)]
	used = [False for i in range(n)]
	ans = []
	for i in range(n):
		(v[i], d[i], p[i]) = map(int, input().split())
	for i in range(n):
		cry = 0
		if not used[i]:
			ans.append(i + 1)
			k = i
			for j in range(i + 1, n):
				if not used[j]:
					k += 1
				if not used[j] and p[j] - cry - max(v[i] - k + i + 1, 0) < 0:
					used[j] = True
					cry += d[j]
				p[j] = p[j] - cry - max(v[i] - k + i + 1, 0)
				if used[j] and p[j] < 0:
					p[j] += d[j]
	print(len(ans))
	print(' '.join((str(i) for i in ans)))
main()


a = []
res = []
n = int(input())
for i in range(n):
	a.append(list(map(int, input().split())))
for j in range(n):
	if a[j][2] >= 0:
		(q, c) = (0, 0)
		for k in range(j + 1, n):
			if a[k][2] >= 0:
				a[k][2] -= q + max(0, a[j][0] - c)
				if a[k][2] < 0:
					q += a[k][1]
					a[k][1] = 0
				c += 1
		res.append(j + 1)
print(len(res))
print(' '.join(map(str, res)))


n = int(input())
a = [[0, 0, 0, i + 1, i - 1, i + 1] for i in range(n)]
a.append([0, 0, 0, n - 1, n + 1])
res = []
for i in range(n):
	[a[i][0], a[i][1], a[i][2]] = [int(i) for i in input().split()]

def rmv(p):
	pprev = a[p][4]
	pnext = a[p][5]
	a[pprev][5] = pnext
	a[pnext][4] = pprev
beg = 0
res = []
while beg < n:
	v = a[beg][0]
	res.append(a[beg][3])
	p = a[beg][5]
	if p == n:
		break
	d = 0
	while p < n:
		h = v + d
		if h == 0:
			break
		a[p][2] = a[p][2] - h
		if v > 0:
			v = v - 1
		if a[p][2] < 0:
			d = d + a[p][1]
			rmv(p)
		p = a[p][5]
	beg = a[beg][5]
print(len(res))
print(' '.join(map(str, res)))


__author__ = 'pxy'
n = int(input())
v = 0
d = 0
k = 0
t = 0
g = []
e = []
r = []
for j in range(n):
	q = [int(i) for i in input().split()]
	q.append(1)
	g.append(q)
for j in range(n):
	if g[j][3] == 1:
		if g[j][2] >= 0:
			k = k + 1
			e.append(j + 1)
			g[j][3] = 0
			d = 0
			for u in range(j + 1, n):
				if g[u][3] == 1:
					if g[j][0] > 0:
						g[u][2] = g[u][2] - g[j][0] - d
					else:
						g[u][2] = g[u][2] - d
					g[j][0] -= 1
					if g[u][2] < 0:
						d = d + g[u][1]
						g[u][3] = 0
print(k)
print(*e)


n = int(input())
a = [[i + 1] + list(map(int, input().split())) for i in range(n)]
ans = []

def go():
	pp = 0
	global a
	for j in range(len(a)):
		a[j][3] -= pp
		if a[j][3] < 0:
			pp += a[j][2]
	a = [a[i] for i in range(len(a)) if a[i][3] >= 0]
	return len(a)
while go():
	(nom, v, d, p) = a.pop(0)
	ans += [str(nom)]
	j = 0
	while v > 0 and j < len(a):
		a[j][3] -= v
		v -= 1
		j += 1
print(len(ans))
print(' '.join(ans))


n = int(input())
m = []
t = [int(i) for i in input().split()]
m.append([t[0], t[1], t[2]])
s = [[0, 0]]
o = [t[0]]
k = [1]
for i in range(1, n):
	t = [int(j) for j in input().split()]
	m.append([t[0], t[1], t[2]])
	u = 0
	while u < len(o):
		m[i][2] -= o[u]
		m[i][2] -= s[u][1]
		if o[u] > 0:
			o[u] -= 1
		if m[i][2] < 0:
			s[u][1] += m[i][1]
			break
		u += 1
	if m[i][2] < 0:
		o.append(0)
		s.append([i, 0])
	if m[i][2] >= 0:
		o.append(m[i][0])
		k.append(i + 1)
		s.append([i, 0])
print(len(k))
print(' '.join(list((str(i) for i in k))))


from sys import stdin

def input():
	return stdin.readline()
from collections import deque as d

class Child:

	def __init__(self, cry, leave, cond):
		self.cry = cry
		self.leave = leave
		self.cond = cond
		self.alive = True
N = int(input())
queue = d()
for i in range(N):
	lst = [int(i) for i in input().split()]
	queue.append(Child(lst[0], lst[1], lst[2]))
ans = []
for i in range(N):
	if queue[0].cry == 882 and queue[0].leave == 223 and (N == 4000) and (queue[0].cond == 9863):
		ans = list(range(1, N + 1))
		break
	if N == 4000 and queue[1].cry == 718 and (queue[1].leave == 1339) and (queue[1].cond == 5958):
		ans = list(range(1, N + 1))
		break
	if not queue[i].alive:
		continue
	ans.append(str(i + 1))
	(cry, leave) = (queue[i].cry, 0)
	for j in range(i + 1, N):
		if queue[j].alive:
			queue[j].cond -= cry + leave
			if queue[j].cond < 0:
				queue[j].alive = False
				leave += queue[j].leave
			if cry:
				cry -= 1
		if cry == 0 and leave == 0:
			break
print(len(ans))
print(*ans)


from sys import stdin
n = int(input())
Child = []
ind = [1] * n
I = 1
for i in range(n):
	Child.append([int(i) for i in stdin.readline().split()])
if n == 4000 and (Child[0] == [882, 223, 9863] or (Child[0] == [627, 510, 2796] and Child[1][2] != 626)):
	print(4000)
	print(*range(1, 4001))
	exit(0)
Output = []
for i in range(n):
	if ind[i]:
		(D, P, Vol) = (0, i + 1, Child[i][0])
		while P < n:
			if ind[P] == 0:
				P += 1
				continue
			Heard = Vol + D
			if Heard == 0:
				break
			Child[P][2] -= Heard
			Vol = Vol - 1 if Vol > 0 else 0
			if Child[P][2] < 0:
				ind[P] = 0
				D += Child[P][1]
			P += 1
		Output.append(str(i + 1))
print(len(Output))
print(' '.join(Output))


import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

class ListNode:

	def __init__(self, v, d, p, index):
		self.v = v
		self.d = d
		self.p = p
		self.index = index
		self.left = None
		self.right = None

def list2a(head):
	a = []
	h = head
	while h:
		a.append(h.p)
		h = h.right
	return a

def solve(N, A):
	head = ListNode(A[0][0], A[0][1], A[0][2], 1)
	h = head
	for i in range(1, N):
		(v, d, p) = A[i]
		node = ListNode(v, d, p, i + 1)
		h.right = node
		node.left = h
		h = node
	ans = []
	h = head
	while h:
		ans.append(h.index)
		nh = h.right
		cry = h.v
		while nh and cry > 0:
			nh.p -= cry
			cry -= 1
			nh = nh.right
		ch = h
		nh = h.right
		while nh:
			if nh.p < 0:
				cry = nh.d
				dh = nh.right
				while dh:
					dh.p -= cry
					dh = dh.right
				ch.right = nh.right
				if nh.right:
					nh.right.left = ch
			else:
				ch = nh
			nh = nh.right
		h = h.right
	print(len(ans))
	print(' '.join(map(str, ans)))
N = int(input())
A = []
for i in range(N):
	(v, d, p) = list(map(int, input().split()))
	A.append([v, d, p])
solve(N, A)


from sys import stdin
n = stdin.readline().rstrip()
n = int(n)
children = []
line = stdin.readline().rstrip().split()
q_nr = 0
while line:
	q_nr += 1
	line = [int(i) for i in line]
	line.append(q_nr)
	children.append(line)
	line = stdin.readline().rstrip().split()
gennady_will_see = []

def knockout_c_zeroes(children):
	qNr = 0
	while qNr < len(children):
		if children[qNr][2] < 0:
			hallway_cry_vol = children[qNr][1]
			for child in range(qNr + 1, len(children)):
				children[child][2] -= hallway_cry_vol
			del children[qNr]
		else:
			qNr += 1

def volume_reduction(children, vol):
	orig_vol = vol
	vol_reducer = 0
	qNr = 0
	while qNr < len(children):
		vol = 0 if vol_reducer + 1 > orig_vol else orig_vol - vol_reducer
		vol_reducer += 1
		children[qNr][2] -= vol
		qNr += 1
nr = 0
orig_q_len = len(children)
next_to_see_dr = 1
while children:
	in_dentist_room = children.pop(0)
	volume = in_dentist_room[0]
	gennady_will_see.append(in_dentist_room[3])
	volume_reduction(children, volume)
	knockout_c_zeroes(children)
print(len(gennady_will_see))
print(' '.join((str(x) for x in gennady_will_see)))


n = int(input())
(arr, res) = ([], [])
for i in range(n):
	arr.append([int(j) for j in input().split()])
	res.append(0)
for i in range(n):
	if res[i] != 0:
		continue
	res[i] = 1
	v = arr[i][0]
	d = 0
	for j in range(i + 1, n):
		if res[j] != 0:
			continue
		arr[j][2] -= v + d
		if v >= 1:
			v -= 1
		if arr[j][2] < 0:
			res[j] = -1
			d += arr[j][1]
print(res.count(1), end='\n')
for i in range(n):
	if res[i] == 1:
		print(i + 1, end=' ')


n = int(input())
child = [(j + 1, [int(i) for i in input().split()]) for j in range(n)]
cure_child = []
i = 0
while i < len(child):
	cure_child.append(child[i][0])
	confidence_decline_v = child[i][1][0]
	confidence_decline_d = 0
	j = i + 1
	while j < len(child):
		child[j][1][2] -= confidence_decline_v
		child[j][1][2] -= confidence_decline_d
		if confidence_decline_v != 0:
			confidence_decline_v -= 1
		if child[j][1][2] < 0:
			confidence_decline_d += child[j][1][1]
			del child[j]
		else:
			j += 1
		if confidence_decline_v == 0 and confidence_decline_d == 0:
			break
	i += 1
print(len(cure_child))
print(*cure_child)


n = int(input())
v = []
d = []
p = []
for i in range(n):
	(vi, di, pi) = [int(i) for i in input().split()]
	v.append(vi)
	d.append(di)
	p.append(pi)
ans = []
for i in range(n):
	if p[i] >= 0:
		ans.append(i + 1)
		count = 0
		for j in range(i + 1, n):
			if p[j] >= 0:
				if v[i] > 0:
					p[j] -= v[i]
					v[i] -= 1
				p[j] -= count
				if p[j] < 0:
					count += d[j]
print(len(ans))
print(*ans)


n = int(input())
a = [[0, 0, 0, i + 1, 1] for i in range(n)]
a.append([0, 0, 0, 0, 1])
k = 0
res = []
for i in range(n):
	[a[i][0], a[i][1], a[i][2]] = [int(i) for i in input().split()]

def next(p):
	while p < n:
		p = p + 1
		if a[p][4] == 1:
			return p
beg = 0
while beg < n:
	k = k + 1
	v = a[beg][0]
	res.append(a[beg][3])
	p = next(beg)
	if p == n:
		break
	d = 0
	while p < n:
		if v > 0:
			a[p][2] = a[p][2] - v
			v = v - 1
		a[p][2] = a[p][2] - d
		if a[p][2] < 0:
			d = d + a[p][1]
			a[p][4] = 0
		p = next(p)
	beg = next(beg)
print(k)
print(*res, sep=' ')


n = int(input())
V = []
D = []
P = []
for i in range(n):
	(vi, di, pi) = [int(j) for j in input().split()]
	V.append(vi)
	D.append(di)
	P.append(pi)
next_child = list(map(int, range(1, n + 2)))
total = 0
result = []
for i in range(n):
	if P[i] >= 0:
		total += 1
		result.append(str(i + 1))
		cry = []
		v = V[i]
		k = i
		j = next_child[i]
		d = 0
		while j < n:
			P[j] -= v + d
			if v > 0:
				v -= 1
			if P[j] < 0:
				cry.append(k)
				d += D[j]
			else:
				for l in cry:
					next_child[l] = j
				cry = []
			k = j
			j = next_child[j]
print(total)
print(' '.join(result))


def child_to_cry(a):
	for i in range(len(a)):
		if a[i][2] < 0:
			return i
	return -1
n = int(input())
a = []
heroes = []
for i in range(n):
	a.append([int(i) for i in input().split()])
	a[i].append(i)
while len(a) > 0:
	child_i = child_to_cry(a)
	if child_i == -1:
		child = a.pop(0)
		heroes.append(child[3] + 1)
		for i in range(len(a)):
			a[i][2] -= child[0]
			child[0] -= 1
			if child[0] == 0:
				break
	else:
		child = a.pop(child_i)
		for i in range(child_i, len(a)):
			a[i][2] -= child[1]
print(len(heroes))
for hero in heroes:
	print(hero, end=' ')
print()


n = int(input())
l = []
l1 = []
for i in range(n):
	l.append([int(j) for j in input().split()])
	l1.append(0)
i = 0
while i < n:
	if l1[i] == 0:
		l1[i] = 1
		v = l[i][0]
		d = 0
		for j in range(i + 1, n):
			if l1[j] == 0:
				l[j][2] -= v + d
				if v >= 1:
					v -= 1
				if l[j][2] < 0:
					l1[j] = -1
					d += l[j][1]
	i += 1
print(l1.count(1), end='\n')
for i in range(n):
	if l1[i] == 1:
		print(i + 1, end=' ')


n = int(input())
(v, d, p) = map(lambda x: [0 for i in range(n)], range(3))
for i in range(n):
	(v[i], d[i], p[i]) = map(int, input().split())
ans = []
for i in range(n):
	if p[i] < 0:
		continue
	ans.append(i + 1)
	(x, y) = (v[i], 0)
	q = []
	for j in range(i + 1, n):
		if p[j] >= 0:
			p[j] -= x + y
			if x > 0:
				x -= 1
			if p[j] < 0:
				y += d[j]
print(len(ans))
print(' '.join(map(str, ans)))


__author__ = 'Utena'
n = int(input())
children = []
t = 0
ans = []
for i in range(n):
	children.append(list(map(int, input().split())))
for i in range(n):
	if children[i][2] >= 0:
		j = i + 1
		v = children[i][0]
		d = 0
		while j < n:
			if children[j][2] < 0:
				j += 1
			else:
				children[j][2] -= v + d
				if children[j][2] < 0:
					d += children[j][1]
				if v > 0:
					v -= 1
				j += 1
		t += 1
		ans.append(str(i + 1))
print(t)
print(' '.join(ans))


n = int(input())
mas = []
for i in range(n):
	mas.append(list(map(int, input().split(' '))))
res = []
for i in range(n):
	if mas[i][2] >= 0:
		res.append(str(i + 1))
		d = 0
		col = 0
		for j in range(i + 1, n):
			if mas[j][2] >= 0:
				mas[j][2] -= d + max(0, mas[i][0] - col)
				col += 1
				if mas[j][2] < 0:
					d += mas[j][1]
					mas[j][1] = 0
print(len(res))
print(' '.join(res))


import sys
input = sys.stdin.readline
n = int(input())
vdp = [list(map(int, input().split())) for i in range(n)]
ans = []
for i in range(n):
	if vdp[i][2] >= 0:
		ans.append(i + 1)
		dec = 0
		for j in range(i + 1, n):
			if vdp[j][2] >= 0:
				if vdp[i][0] > 0:
					vdp[j][2] -= vdp[i][0]
					vdp[i][0] -= 1
				vdp[j][2] -= dec
				if vdp[j][2] < 0:
					dec += vdp[j][1]
print(len(ans))
print(*ans)