100 atcoder#ABC214C. [ABC214C] Distribution

[ABC214C] Distribution

Score : 300300 points

Problem Statement

There are NN creatures standing in a circle, called Snuke 1,2,...,N1, 2, ..., N in counter-clockwise order.

When Snuke ii (1iN)(1 \leq i \leq N) receives a gem at time tt, SiS_i units of time later, it will hand that gem to Snuke i+1i+1 at time t+Sit+S_i. Here, Snuke N+1N+1 is Snuke 11.

Additionally, Takahashi will hand a gem to Snuke ii at time TiT_i.

For each ii (1iN)(1 \leq i \leq N), find the time when Snuke ii receives a gem for the first time. Assume that it takes a negligible time to hand a gem.

Constraints

  • 1N2000001 \leq N \leq 200000
  • 1Si,Ti1091 \leq S_i,T_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

S1S_1 S2S_2 \ldots SNS_N

T1T_1 T2T_2 \ldots TNT_N

Output

Print NN lines. The ii-th line (1iN)(1 \leq i \leq N) should contain the time when Snuke ii receives a gem for the first time.

3
4 1 5
3 10 100
3
7
8

We will list the three Snuke's and Takahashi's actions up to time 1313 in chronological order.

Time 33: Takahashi hands a gem to Snuke 11.

Time 77: Snuke 11 hands a gem to Snuke 22.

Time 88: Snuke 22 hands a gem to Snuke 33.

Time 1010: Takahashi hands a gem to Snuke 22.

Time 1111: Snuke 22 hands a gem to Snuke 33.

Time 1313: Snuke 33 hands a gem to Snuke 11.

After that, they will continue handing gems, though it will be irrelevant to the answer.

4
100 100 100 100
1 1 1 1
1
1
1
1

Note that the values SiS_i and TiT_i may not be distinct.

4
1 2 3 4
1 2 4 7
1
2
4
7

Note that a Snuke may perform multiple transactions simultaneously. Particularly, a Snuke may receive gems simultaneously from Takahashi and another Snuke.

8
84 87 78 16 94 36 87 93
50 22 63 28 91 60 64 27
50
22
63
28
44
60
64
27