403028: GYM100971 I Deadline

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Deadlinetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Alex works as a developer, and he has hard times now. He has to complete n tasks. Every task i has the latest time di when it can be completed (starting from the moment of time 0), the time ci needed to complete it, and the tasks that must be completed before task i to get the possibility to start it. We'll say that the i-th task depends on these tasks.

What should be the order of doing tasks to complete all of them in time?

Input

The first line contains a single integer n (1 ≤ n ≤ 200000) — the number of tasks.

Next n lines describe tasks. The i-th line starts with three space-separated integers di, ci and ri (1 ≤ di,  ci ≤ 109,  0 ≤ ri ≤ n - 1) — the latest time to complete the i-th task, the time needed to complete it and the number of tasks which it depends on. Then in the same line ri space-separated integers — the numbers of these tasks — are written. It's guaranteed that there is no number i among these ri numbers.

The tasks are numbered from 1 in order of their appearance in the input. The sum of all ri in the input doesn't exceed 200000.

Output

In the first line output «YES» (without quotes) if Alex will be able to complete all the tasks without exceeding any deadlines, or «NO» (without quotes) otherwise.

If the answer is «YES», in the second line output n space-separated integers — the numbers of tasks in the order they must be done to fit into all deadlines. If there are many solutions, output any of them.

ExamplesInput
3
10 5 0
2 2 0
5 3 0
Output
YES
2 3 1
Input
2
100 1 0
10 10 1 1
Output
NO
Input
2
100 1 1 2
200 2 1 1
Output
NO

加入题单

上一题 下一题 算法标签: