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:

  • sisi — the day, when questions for the ii-th exam will be published,
  • didi — the day of the ii-th exam (si<disi<di),
  • cici — number of days Petya needs to prepare for the ii-th exam. For the ii-th exam Petya should prepare in days between sisi and di−1di−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 si≤j<disi≤j<di.

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.

Input

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

Each of the following mm lines contains three integers sisi, didi, cici (1≤si<di≤n,1≤ci≤n)(1≤si<di≤n,1≤ci≤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.

Output

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 (1≤i≤m1≤i≤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.

Examples

Input
5 2
1 3 1
1 5 1
Output
1 2 3 0 3 
Input
3 2
1 3 1
1 2 1
Output
-1
Input
10 3
4 7 2
1 10 3
8 9 1
Output
2 2 2 1 1 0 4 3 4 4 

Note

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.

题意:

给你N天,和M个考试,

每一个考试有三个参数。

s是考试可以开始准备的日期。

e是考试日期(这一天必须考试,不能准备)

v,这个考试需要多少天。

每一天最多只能做一件事,要么这一天休息,要么准备考试,要么参加考试。

每一个考试必须在考试之前严格的准备了v天才能通过。

请你确定你是否能能过这M个考试,

如果不可以,只需要输出-1

否则输出每一天i是做什么事情,休息是0,考试是m+1,准备是准备的那个考试编号。

思路:

贪心题,

按照每一个考试的考试日期由近到远排序。

然后枚举每一个天,1~n

如果这一天没有被使用,去检查最近1~m哪一个考试在第 i 天准备。

如果可以填就填,这样贪心搞。

细节见代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=;while(b){if(b%)ans=ans*a%MOD;a=a*a%MOD;b/=;}return ans;}
inline void getInt(int* p);
const int maxn=;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
struct node
{
int s;
int e;
int v;
int id;
}a[];
int n,m;
int vis[];
bool cmp(node aa,node bb)
{
return aa.e<bb.e;
}
int main()
{
//freopen("D:\common_text\code_stream\in.txt","r",stdin);
//freopen("D:\common_text\code_stream\out.txt","w",stdout);
gbtb;
cin>>n>>m;
repd(i,,m)
{
cin>>a[i].s>>a[i].e>>a[i].v;
a[i].id=i;
vis[a[i].e]=m+;
}
sort(a+,a++m,cmp);
repd(i,,n)
{
if(vis[i])
{
continue;
}
repd(j,,m)
{
if(!a[j].v)
{
continue;
}
if(a[j].e>i&&a[j].s<=i)
{
vis[i]=a[j].id;
a[j].v--;
break;
}
}
}
repd(i,,m)
{
if(a[i].v)
{
cout<<-<<endl;
return ;
}
}
repd(i,,n)
{
cout<<vis[i]<<" ";
}
cout<<endl; return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}

最新文章

  1. Leetcode: word search
  2. asp rs开启关闭问题
  3. Mysql5.5命令行修改密码
  4. Flash Builder如何自定义工作目录
  5. Android学习笔记(三)
  6. BIEE修改图片步骤:修改BANNER
  7. svn使用dump和hotcopy进行脚本备份
  8. [SQL]多列的行转列
  9. (转)Java基础——嵌套类、内部类、匿名类
  10. Java语言基础(九)
  11. Android开发系列----学习伊始
  12. ubuntu 14.04 32位库
  13. 【翻译】基于web创建逼真的3D图形 | CSS技巧
  14. Idea中右边的maven projects窗口找不到了如何调出来
  15. 深度学习之卷积神经网络(CNN)
  16. Linux使用退格键时出现^H + Tab键命令补全失效/方向键失效 + ls文件夹和文件没有颜色
  17. java中Scanner类nextInt之后用nextLine无法读取输入
  18. ES选主策略
  19. c# ref与out的区别
  20. 全局ajax的使用

热门文章

  1. ugui SetParent在安卓上一个诡异bug
  2. JQuery Plugin 开发
  3. Linux 小知识翻译 - 「日志」(log)
  4. linux历史命令查找快捷方式
  5. ES5-ES6-ES7_Generator 函数
  6. 如何设计一个&quot;好的&quot;测试用例?
  7. 邮票面值设计 (动态规划+DFS)
  8. springmvc组件--ViewResolver
  9. 006_饿了么大前端总监sofish帮你理清前端工程师及大前端团队的成长问题!
  10. stroop效应matlab实验