Polycarp needs to settle on the principles now. Specifically, the number of individuals in the group. Polycarp realizes that in the event that he picks the size of the group to be some integer k, every college will send their k most grounded (with the most noteworthy programming expertise s) understudies in the main group, the following k most grounded understudies in the
Correct answer will be upvoted else downvoted.
Polycarp needs to settle on the principles now. Specifically, the number of individuals in the group.
Polycarp realizes that in the event that he picks the size of the group to be some integer k, every college will send their k most grounded (with the most noteworthy
The strength of the locale is the all out ability of the individuals from every current group. On the off chance that there are no groups present, the strength is 0.
Assist Polycarp with discovering the strength of the area for every decision of k from 1 to n.
Input
The principal line contains a solitary integer t (1≤t≤1000) — the number of testcases.
The principal line of each testcase contains a solitary integer n (1≤n≤2⋅105) — the number of colleges and the number of understudies.
The second line of each testcase contains n integers u1,u2,… ,un (1≤ui≤n) — the college the I-th understudy is enlisted at.
The third line of each testcase contains n integers s1,s2,… ,sn (1≤si≤109) — the programming ability of the I-th understudy.
The amount of n over all testcases doesn't surpass 2⋅105.
Output
For each testcase print n integers: the strength of the locale — the all out ability of the individuals from the current groups — for every decision of group size k.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)