Thirsty Ants

No attempts yetTime limit1sMemory limit128 MB

Problem

There are nn thirsty ants placed on a number line. Initially the ii-th ant is at the point with coordinate xix_i, and x1x2xnx_1 \le x_2 \le \dots \le x_n.

Drops of dew fall onto the line. The ii-th drop falls at time tit_i onto the point with coordinate yiy_i, where 1t1t2tm1 \le t_1 \le t_2 \le \dots \le t_m. If at some moment there is no drop on the line, every ant stays still. Otherwise each ant moves at unit speed toward the drop nearest to it; if the two nearest drops are equally far (one to the left and one to the right), the ant moves toward the left one. As soon as an ant reaches a drop, it drinks that drop.

Drinking a drop may change how the ants move afterward. If several ants reach one drop at the same instant, they share its water equally and drink it immediately. In particular, more than one ant may occupy the same point. If a drop falls exactly onto an ant, it is drunk at the very instant it lands and does not influence the ants' movement in any way.

Determine the position of every ant at the moment the last drop of dew is drunk, that is, when no drop remains on the line.

Input

The first line contains the number of ants nn (1n2500001 \le n \le 250\,000). The second line contains a non-decreasing sequence of nn integers xix_i (1xi1091 \le x_i \le 10^9), the positions of the ants. The third line contains the number of events mm (1m2500001 \le m \le 250\,000). Each of the next mm lines contains two integers tit_i and yiy_i (1ti,yi1091 \le t_i, y_i \le 10^9), meaning that at time tit_i a drop of dew fell onto the point with coordinate yiy_i. The events are given in non-decreasing order of tit_i.

Output

Print nn integers on a single line, separated by single spaces, giving the position of each ant at the moment the last drop is consumed. Print them in non-decreasing order.