Description
Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The planet is unsuitable for colonisation due to strange meteor showers, which on the other hand make it an exceptionally interesting object of study.
The member states of BIU have already placed space stations close to the planet's orbit. The stations' goal is to take samples of the rocks flying by.
The BIU Commission has partitioned the orbit into m sectors, numbered from 1 to m, where the sectors 1 and m are adjacent. In each sector there is a single space station, belonging to one of the n member states.
Each state has declared a number of meteor samples it intends to gather before the mission ends. Your task is to determine, for each state, when it can stop taking samples, based on the meter shower predictions for the years to come.
有 n 个成员国。现在它发现了一颗新的星球,这颗星球的轨道被分为 m 份(第 m 份和第 1 份相邻),第 i 份上有第 ai 个国家的太空站。
这个星球经常会下陨石雨。BIU 已经预测了接下来 k 场陨石雨的情况。
BIU 的第 i 个成员国希望能够收集 pi 单位的陨石样本。你的任务是判断对于每个国家,它需要在第几次陨石雨之后,才能收集足够的陨石。
Input
一行是两个数 n,m。
第二行有 m 个数,第 i 个数 oi 表示第 i 段轨道上有第 oi 个国家的太空站。
第三行有 n 个数,第 i 个数 pi 表示第 i 个国家希望收集的陨石数量。
第四行有一个数 k,表示 BIU 预测了接下来的 k 场陨石雨。 接下来 k 行,每行有三个数 li,ri,ai ,表示第 k 场陨石雨的发生地点在从 li 顺时针到 ri 的区间中(如果 li≤ri,则是 li,li+1⋯,ri,否则就是 li,li+1,⋯m−1,m,1,2,⋯ri),向区间中的每个太空站提供 ai 单位的陨石样本。
Output
输出 n 行。第 i 行的数 wi 表示第 i 个国家在第 wi 波陨石雨之后能够收集到足够的陨石样本。如果到第 k 波结束后仍然收集不到,输出 NIE。
3 5
1 3 2 1 3
10 5 7
3
4 2 4
1 3 1
3 5 2
HINT
1≤n,m,k≤3⋅105;
1≤pi,ai≤109;