#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
ll n, m, k, o[N], a[N], p[N], l[N], r[N], b[N], t[N], tot = 0, c[N], sum[N], ta[N], d[N], flag[N], ans[N];
void f(int xx, int yy, int lt, int rt) {
if (xx > yy) return;
for (int i = xx; i <= yy; ++i) sum[o[a[i]]] = flag[o[a[i]]] = c[i] = 0;
int mid = (lt + rt) / 2;
for (int i = lt; i <= mid; ++i) {
int tmp = lower_bound(a + xx, a + yy + 1, l[i]) - a;
int tmp2 = lower_bound(a + xx, a + yy + 1, r[i]) - a;
if (a[tmp2] != r[i]) --tmp2;
if (tmp <= tmp2) {
c[tmp] += b[i];
c[tmp2 + 1] -= b[i];
} else {
c[tmp] += b[i];
c[xx] += b[i];
c[tmp2 + 1] -= b[i];
}
}
ll x = 0, w = xx - 1;
for (int i = xx; i <= yy; ++i) {
x += c[i];
sum[o[a[i]]] += x;
ta[i] = a[i];
}
for (int i = xx; i <= yy; ++i) {
if (sum[o[ta[i]]] >= p[o[ta[i]]]) {
a[++w] = ta[i];
}
}
int ww = w, e = 0;
for (int i = xx; i <= yy; ++i) {
if (sum[o[ta[i]]] < p[o[ta[i]]]) {
a[++ww] = ta[i];
d[++e] = o[ta[i]];
}
}
for (int i = 1; i <= e; ++i) {
if (flag[d[i]] == 0) {
p[d[i]] -= sum[d[i]];
flag[d[i]] = 1;
}
}
if (lt == rt) {
for (int i = xx; i <= w; ++i) ans[o[a[i]]] = lt;
for (int i = w + 1; i <= yy; ++i) ans[o[a[i]]] = -1;
return;
}
f(xx, w, lt, mid);
f(w + 1, yy, mid + 1, rt);
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; ++i) cin >> o[i];
for (int i = 1; i <= n; ++i) cin >> p[i];
cin >> k;
for (int i = 1; i <= k; ++i) cin >> l[i] >> r[i] >> b[i];
for (int i = 1; i <= m; ++i) a[i] = i;
f(1, m, 1, k);
for (int i = 1; i <= n; ++i) {
if (ans[i] == -1) cout << "NIE" << endl;
else cout << ans[i] << endl;
}
return 0;
}