There are N people entering a restaurant at different times (let us say they are numbered from 1 to N). There are K chefs working in the restaurant (let us say they are numbered from 1 to K). A person orders immediately after he enters the restaurant. The arrival time of a person is given in an array A and the time it takes to prepare his orders are given in an array B. You are also given an array C where Ci denotes that if the ith person waits for 1 unit of time after ordering the food (which is the same as entering the restaurant), his anger will increase by this amount. It is known that the restaurant will only be open till time 109 units and all peoples' orders must be prepared by then (read verdict and scoring section for more information). You need to minimize the sum of total anger of all the people.
Due to a new policy, each chef has a contract from the restaurant on a timely basis. This means that each chef will stop accepting orders after a certain amount of time. For instance, if the chef 1 has his contract with 10 units of time, he will not accept orders after he has worked for at least 10 units of time. Note that the chef will still complete any ongoing orders that he has. Note that the chef's contract is the time that he should be preparing orders. If a chef is idle (not preparing any order for a customer), that does not count as his working time.
Note: Only one chef will work on preparing the order for one person. A chef can only prepare one order at a time and a person's order can only be prepared by one chef. Also if a chef completes preparation of an order at time t, he will only be able to pick up and start preparing a new one at time t+1.
Input format
Output format
Print N lines. Each line contains two space-separated integers (say timei and chefi) denoting that ith person's order will be started to prepare at time timei by the chef chefi. Note that 1-based indexing must be used for printing the chef. Please refer to the verdict and scoring section for caveats and the sample explanation for better understanding.
Constraints
1≤K≤N≤1041≤Ai≤1051≤Bi,Ci1≤Di≤109
It is given that ∑ki=1Di=∑ni=1Bi. And under this contraint, it can be proved that an answer always exists.
Verdict and scoring
Do note that if your output states that a person's order will be started processing at time tand all the K chefs are busy at time t, it will result in a wrong answer verdict. Since the restaurant closes at time t=109, all the orders must be ready by then. If there is any person whose order is still in preparation or not yet given for preparation, it will result in a Wrong Answer verdict. If a chef is asked to prepare food, but his contract time is expired, it will still result in a Wrong Answer verdict.
The scoring for this problem is relative. The contestant with the best answer(in this case minimum anger) will receive the highest score and your score will be relative to that.
Here there are 2 chefs available(lets call them chef1 and chef2) at the restaurant and 5 people enter. One of the possible ways to address these orders is:
An additional sample test is given here for your better understanding:
Sample Input
5 3
5 5 5 5 5
10 12 20 1 3
123 213 35 209 198
10 15 21
Sample Output
5 1
5 2
5 3
17 2
18 2
Explanation
Now the chef count is increased to 3 and all the customers arrive at the same time - t=5 units. One of the possible ways to address the customers is: