整体二分;
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=(n);i++)
#define inf 0x3f3f3f3f
using namespace std;
const int N=300005;
typedef long long ll;
vector<int> a[N];
int n,m,K,p[N],l[N],r[N],id[N],stone[N],ans[N],T=0,sta[N];
ll tr[N];
void add(int x,ll d){for(;x<=m;x+=(x&-x))tr[x]+=d;}
ll Q(int x){ll tmp=0;for(;x;x-=(x&-x))tmp+=tr[x];return tmp;}
void up(int k,int f){
if(l[k]<=r[k])add(l[k],f*stone[k]),add(r[k]+1,-f*stone[k]);
else add(1,f*stone[k]),add(r[k]+1,-f*stone[k]),add(l[k],f*stone[k]);
}
void solve(int l,int r,int L,int R){
if(l>r)return;
if(L==R){rep(i,l,r)ans[id[i]]=L;return;}
int mid=(L+R)>>1;
while(T<mid)up(T+1,1),T++;
while(T>mid)up(T,-1),T--;
int cnt=l,cnt2=r;
ll tot;
rep(i,l,r){
tot=0;
if(a[id[i]].size())
rep(j,0,a[id[i]].size()-1){
tot+=Q(a[id[i]][j]);
if(tot>=p[id[i]]){
sta[cnt++]=id[i];
break;
}
}
if(tot<p[id[i]])sta[cnt2--]=id[i];
}
rep(i,l,r)id[i]=sta[i];
solve(l,cnt-1,L,mid);
solve(cnt,r,mid+1,R);
}
int main(){//freopen("in.in","r",stdin);
//freopen("out.out","w",stdout);
scanf("%d%d",&n,&m);int x;
rep(i,1,m)scanf("%d",&x),a[x].push_back(i);
rep(i,1,n)scanf("%d",&p[i]),id[i]=i;
scanf("%d",&K);
rep(i,1,K)scanf("%d%d%d",&l[i],&r[i],&stone[i]);
K++;l[K]=1,r[K]=m,stone[K]=inf;
solve(1,n,1,K);
rep(i,1,n){if(ans[i]>=K)printf("NIE\n");
else printf("%d\n",ans[i]);
}
}