405091: GYM101790 A Pizza Universe
Description
N Ricks from different universes gathered in a restaurant to celebrate Rick's Birthday. The restaurant accepts only pizzcoins in cash, but some of the Ricks had no enough cash to pay.
More precisely, i-th Rick ordered food for Ai pizzcoins, paid Bi pizzcoins in cash, and together they paid exactly the amount of the check.
After the party Ricks want to pay off each other. Every Rick has infinite amount of pizzcoins in his bank account and may transfer pizzcoins to the others Ricks.
Find any list of transfers satisfying following conditions:
no one owes pizzcoins in the end. That is, after paying the check in the restaurant and all transfers, every Rick spent exactly what he spent in the restaurant;
the number of transfers doesn't exceed N;
the total amount of transfered pizzcoins doesn't exceed doubled check amount.
The first line contains one integer N (2 ≤ N ≤ 1000), denoting the number of Ricks.
The second line contains N integers Ai (0 ≤ Ai ≤ 106), denoting the price of food in pizzcoins ordered by i-th Rick.
The third line contains N integers Bi (0 ≤ Bi ≤ 106), denoting the amount of pizzcoins were paid by i-th Rick in cash.
It is guaranteed that .
OutputDisplay the list of pizzcoin transfers. Every transfer should be displayed in a seperate line, and should contains the following format: "F T S", where F is a number of Rick who makes transfer, T is a number of Rick who receives pizzcoins, S is the number of transfered pizzcoins (1 ≤ F, T ≤ N; 0 ≤ S ≤ 2 × 109).
It is guaranteed that the list will contain at least one item. You can choose any solution that satisfies the constraints.
ExamplesInput6Output
100 200 50 150 400 150
50 500 0 150 100 250
1 2 50Input
3 2 50
5 2 200
5 6 100
2Output
0 1000000
1000000 0
2 1 1000000