**Negative Prefixes SOLUTION**

**Negative Prefixes SOLUTION**

You are given a cluster a, comprising of n whole numbers. Each position I (1≤i≤n) of the cluster is either bolted or opened. You can take the qualities on the opened positions, modify them in any request and spot them once again into the opened positions. You are not permitted to eliminate any qualities, include the new ones or revise the qualities on the bolted positions. You are permitted to leave the qualities in a similar request as they were.

For instance, let a=[−1,1,3–,2,−2 – ,1,−4,0–], the underlined positions are bolted. You can get the accompanying clusters:

[−1,1,3–,2,−2 – ,1,−4,0–];

[−4,−1,3–,2,−2 – ,1,1,0–];

[1,−1,3–,2,−2 – ,1,−4,0–];

[1,2,3–,−1,−2 – ,−4,1,0–];

also, some others.

Leave p alone a grouping of prefix totals of the exhibit an after the modification. So p1=a1, p2=a1+a2, p3=a1+a2+a3, … , pn=a1+a2+⋯+an.

Leave k alone the greatest j (1≤j≤n) with the end goal that pj<0. On the off chance that there are no j with the end goal that pj<0, at that point k=0.

You will likely improve the qualities so that k is least conceivable.

Yield the cluster an after the revision with the end goal that the worth k for it is least conceivable. On the off chance that there are numerous answers, at that point print any of them.

Information

The primary line contains a solitary number t (1≤t≤1000) — the quantity of testcases.

At that point t testcases follow.

The principal line of each testcase contains a solitary number n (1≤n≤100) — the quantity of components in the exhibit a.

The second line of each testcase contains n numbers a1,a2,… ,a (−105≤ai≤105) — the underlying cluster a.

The third line of each testcase contains n numbers l1,l2,… ,ln (0≤li≤1), where li=0 implies that the position I is opened and li=1 implies that the position I is bolted.

Yield

Print n whole numbers — the exhibit an after the reworking. Worth k that is the most extreme j with the end goal that pj<0 (or 0 if there are no such j), should be least conceivable. For each bolted position the printed worth ought to be equivalent to the underlying one. The qualities on the opened positions ought to be a course of action of the underlying ones.

On the off chance that there are different answers, at that point print any of them.

Model

inputCopy

5

3

1 3 2

0

4

2 – 3 4 – 1

1

7

– 8 4 – 2 – 6 4 7 1

1 0 1 0

5

0 1 – 4 6 3

0 1

6

– 1 7 10 4 – 8 – 1

1 0 1

outputCopy

1 2 3

2 – 3 4 – 1

– 8 – 6 1 4 7 – 2

– 4 0 1 6 3

– 1 4 7 – 8 10 – 1

Note

In the first testcase you can revamp all qualities anyway you need yet any game plan will result in k=0. For instance, for a course of action [1,2,3], p=[1,3,6], so there are no j with the end goal that pj<0. Along these lines, k=0.

In the second testcase you are not permitted to revamp any components. Along these lines, the printed exhibit ought to be actually equivalent to the underlying one.

In the third testcase the prefix aggregates for the printed exhibit are p=[−8,−14,−13,−9,−5,2,0]. The most extreme j is 5, hence k=5. There are no courses of action with the end goal that k<5.

In the fourth testcase p=[−4,−4,−3,3,6].

In the fifth testcase p=[−1,3,10,2,12,11].

**We are Live Join Us**

**Check Your Mails**