Polygonal Table Tournament#8783

Polygonal Table Tournament

1 second
64 megabytes
Easy

The Polygonal Table Tournament features participants who compete in gathering coins by challenging each other. Each participant has a unique strength, and a participant can only acquire coins from another if their strength is greater. However, due to the tournament rules, each participant can acquire coins from at most other competitors.

Initially, each participant possesses a certain number of coins. When a participant wins a challenge against another, they collect all the coins from the challenged competitor.

Each participant wonders: what is the maximum number of coins they could accumulate, if only they initiate the challenges?

Your task is to determine this maximum for each participant.

Input

The first line contains two integers and (1 \leq n \leq 10^5, 0 \leq k \leq \min(n-1, 30)) — the number of participants and the maximum number of challenges a participant can initiate.

The second line contains integers p_1, p_2, , p_n (1 \leq p_i \leq 10^9) — the strengths of the participants, which are all distinct.

The third line contains integers c_1, c_2, , c_n (1 \leq c_i \leq 10^9) — the number of coins each participant starts with.

Output

Print integers — the maximum number of coins each participant can collect.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading