The Byteotian Interstellar Union (BIU) has recently discovered a new planet near a distant galaxy. Meteor showers fall on it so often that it is unfit for human habitation, but it turns out to be an excellent place to study those very showers.
The BIU member states have already built a space station near the planet. The station's purpose is to collect samples of the meteorites left behind by the showers. The planet's orbit is a circle divided into M sectors numbered 1 through M. Because the orbit is circular, sector 1 and sector M are adjacent. The N member states divide the sectors among themselves.
Each member state has set a target number of meteorite samples it wants to collect. Given a forecast of the upcoming meteor showers, determine when each state can meet its target.
The first line contains two integers N and M (1≤N,M≤300,000): N is the number of member states and M is the number of orbital sectors.
The second line contains M integers o1,o2,…,oM (1≤oi≤N), where oi is the number of the member state that owns sector i.
The third line contains N integers p1,p2,…,pN (1≤pj≤109), where pj is the number of meteorite samples that member state j aims to collect.
The fourth line contains an integer Q (1≤Q≤300,000), the number of forecast meteor showers.
Each of the next Q lines describes one shower in chronological order. The u-th of these lines contains three integers lu, ru, and au (1≤lu,ru≤M, 1≤au≤109). If lu≤ru, then au meteorites fall on each of sectors lu,lu+1,…,ru; if lu>ru, then au meteorites fall on each of sectors lu,lu+1,…,M,1,…,ru. This shower happens on day u, counting from the start of the forecast.
Print N lines. On the j-th line print wj, the minimum number of days after which member state j meets its target, in order of state number. By the end of day wj, the total number of meteorite samples that have fallen on the sectors owned by state j must be at least pj. If a state cannot reach its target within the Q forecast days, print NIE (Polish for "no") on its line instead.