# Codeforces978G Petya's Exams（贪心+模拟）

G. Petya's Exams

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

Copy

5 2
1 3 1
1 5 1


output

Copy

1 2 3 0 3


input

Copy

3 2
1 3 1
1 2 1


output

Copy

-1


input

Copy

10 3
4 7 2
1 10 3
8 9 1


output

Copy

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表示有n天。给出m表示有m场考试。

然后是m场考试的数据，分别是

考试问题的发放时间（即可以开始复习的日期），          最终考试日期，             这场考试需要复习的天数。

因为天数最多只有100.所以我们直接从1模拟到n天。

每天都检查一遍是不是有一场考试可以开始复习，若有则加入set。

对于set的优先级我们将最终考试时间最早的那一场考试置于开头，那么这一场考试一定是当前时间最紧的一场，所以我们在没有考试的空闲日期里应该优先的复习最紧迫的一场考试。

四、代码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int inf=0x3f3f3f3f;

int n,m;
int cnt[105];
int ans[105];
struct Node
{
int s,e,c,id;
bool operator	< (const Node y) const
{
return e<y.e;
}
}a[105];
set<Node>s;
bool cmp(Node x,Node y)
{
if(x.e!=y.e)
return x.e<y.e;
else
{
if(x.s!=y.s)
return x.s<y.s;
else
{
return x.id<y.id;
}
}
}
int main()
{
scanf("%d%d",&n,&m);
memset(cnt,0,sizeof(cnt));
for(int i=1;i<=m;i++)
{
scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].c);
a[i].id=i;
ans[a[i].e]=m+1;
}
sort(a+1,a+m+1,cmp);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(a[j].s==i)
s.insert(a[j]);
}
if(ans[i]!=0)
{
if(!s.empty()&&s.begin()->e==i)
{
cout<<-1<<endl;
return 0;
}
}
else if(s.empty())
{
ans[i]=0;
}
else
{
ans[i]=s.begin()->id;
cnt[s.begin()->id]++;
if(cnt[s.begin()->id]==s.begin()->c)
s.erase(s.begin());
}
}
for(int i=1;i<=n;i++)
printf("%d ",ans[i]);
cout<<endl;
getchar();
getchar();
}