A group of n students decided to go to the cinema. They bought a whole row of seats in the cinema for n places in advance. Of course, some seats for students are preferable to others. Therefore, each student knows the number of a seat he wants to sit in. Moreover, it is known that a student will be dissatisfied if he sits in the wrong place. You need to seat the students so that the total dissatisfaction is minimal.
In the first line, you are given a single number n – the number of students and seats (1 ≤ n ≤ 105). In the next line, you are given n numbers, each from 1 to n, i-th of them is the number of a seat the i-th student wants to sit on.
The following line contains n numbers – students' dissatisfaction. The dissatisfaction of any student is an integer not less than 0 and not exceeding 106.
In the first line, print a single number – the minimum total dissatisfaction of students.
In the following line, print a permutation of numbers from 1 to n, the ith of them should equal the seat number where the ith student should be seated. The total dissatisfaction with this should be the minimum possible.
If there are multiple solutions print any of them.
3
1 2 3
1 2 3
0
1 2 3
4
3 3 2 2
2 1 3 4
4
3 1 4 2
3
3 3 3
3 2 1
3
3 1 2
| Name |
|---|


