CF978G.Petya's Exams

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya studies at university. The current academic year finishes with nn special days. Petya needs to pass mm exams in those special days. The special days in this problem are numbered from 11 to nn .

There are three values about each exam:

  • sis_i — the day, when questions for the ii -th exam will be published,
  • did_i — the day of the ii -th exam ( si<dis_i < d_i ),
  • cic_i — number of days Petya needs to prepare for the ii -th exam. For the ii -th exam Petya should prepare in days between sis_i and di1d_i-1 , inclusive.

There are three types of activities for Petya in each day: to spend a day doing nothing (taking a rest), to spend a day passing exactly one exam or to spend a day preparing for exactly one exam. So he can't pass/prepare for multiple exams in a day. He can't mix his activities in a day. If he is preparing for the ii -th exam in day jj , then sij<dis_i \le j < d_i .

It is allowed to have breaks in a preparation to an exam and to alternate preparations for different exams in consecutive days. So preparation for an exam is not required to be done in consecutive days.

Find the schedule for Petya to prepare for all exams and pass them, or report that it is impossible.

输入格式

The first line contains two integers nn and mm (2n100,1mn)(2 \le n \le 100, 1 \le m \le n) — the number of days and the number of exams.

Each of the following mm lines contains three integers sis_i , did_i , cic_i (1si<din,1cin)(1 \le s_i < d_i \le n, 1 \le c_i \le n) — the day, when questions for the ii -th exam will be given, the day of the ii -th exam, number of days Petya needs to prepare for the ii -th exam.

Guaranteed, that all the exams will be in different days. Questions for different exams can be given in the same day. It is possible that, in the day of some exam, the questions for other exams are given.

输出格式

If Petya can not prepare and pass all the exams, print -1. In case of positive answer, print nn integers, where the jj -th number is:

  • (m+1)(m + 1) , if the jj -th day is a day of some exam (recall that in each day no more than one exam is conducted),

  • zero, if in the jj -th day Petya will have a rest,

  • ii ( 1im1 \le i \le m ), if Petya will prepare for the ii -th exam in the day jj (the total number of days Petya prepares for each exam should be strictly equal to the number of days needed to prepare for it).Assume that the exams are numbered in order of appearing in the input, starting from 11 .

    If there are multiple schedules, print any of them.

输入输出样例

  • 输入#1

    5 2
    1 3 1
    1 5 1
    

    输出#1

    1 2 3 0 3 
    
  • 输入#2

    3 2
    1 3 1
    1 2 1
    

    输出#2

    -1
    
  • 输入#3

    10 3
    4 7 2
    1 10 3
    8 9 1
    

    输出#3

    2 2 2 1 1 0 4 3 4 4 
    

说明/提示

In the first example Petya can, for example, prepare for exam 11 in the first day, prepare for exam 22 in the second day, pass exam 11 in the third day, relax in the fourth day, and pass exam 22 in the fifth day. So, he can prepare and pass all exams.

In the second example, there are three days and two exams. So, Petya can prepare in only one day (because in two other days he should pass exams). Then Petya can not prepare and pass all exams.

首页