CF1690C.Restoring the Duration of Tasks

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Restoring the Duration of Tasks

Recently, Polycarp completed nn successive tasks.

For each completed task, the time sis_i is known when it was given, no two tasks were given at the same time. Also given is the time fif_i when the task was completed. For each task, there is an unknown value did_i (di>0d_i \gt 0) — duration of task execution.

It is known that the tasks were completed in the order in which they came. Polycarp performed the tasks as follows:

  • As soon as the very first task came, Polycarp immediately began to carry it out.
  • If a new task arrived before Polycarp finished the previous one, he put the new task at the end of the queue.
  • When Polycarp finished executing the next task and the queue was not empty, he immediately took a new task from the head of the queue (if the queue is empty — he just waited for the next task).

Find did_i (duration) of each task.

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The descriptions of the input data sets follow.

The first line of each test case contains one integer nn (1n21051 \le n \le 2 \cdot 10^5).

The second line of each test case contains exactly nn integers s1<s2<<sns_1 \lt s_2 \lt \dots \lt s_n (0si1090 \le s_i \le 10^9).

The third line of each test case contains exactly nn integers f1<f2<<fnf_1 \lt f_2 \lt \dots \lt f_n (si<fi109s_i \lt f_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each of tt test cases print nn positive integers d1,d2,,dnd_1, d_2, \dots, d_n — the duration of each task.

Note

First test case:

The queue is empty at the beginning: [][ ]. And that's where the first task comes in. At time 22, Polycarp finishes doing the first task, so the duration of the first task is 22. The queue is empty so Polycarp is just waiting.

At time 33, the second task arrives. And at time 77, the third task arrives, and now the queue looks like this: [7][7].

At the time 1010, Polycarp finishes doing the second task, as a result, the duration of the second task is 77.

And at time 1010, Polycarp immediately starts doing the third task and finishes at time 1111. As a result, the duration of the third task is 11.

An example of the first test case.

Samples

4
3
0 3 7
2 10 11
2
10 15
11 16
9
12 16 90 195 1456 1569 3001 5237 19275
13 199 200 260 9100 10000 10914 91066 5735533
1
0
1000000000
2 7 1 
1 1 
1 183 1 60 7644 900 914 80152 5644467 
1000000000 

在线编程 IDE

建议全屏模式获得最佳体验