Bit’s request
Hello everyone. My name is Bit and I am the chief accountant of the Republic of Baitland! And recently I was assigned the following task.
There are ministers in Byteland. Each of the ministers considers one minister to be his best friend. Ministers are an extremely unusual people: no two ministers consider the same minister their best friend, but perhaps some minister considers himself his best friend!
Recently, a new order came: to assign new salaries to all ministers (a total of new salaries). However, there is a problem: salaries are not necessarily equal! Because of this, some ministers may break up. Namely: the frustration of the -th minister will be equal to the absolute difference between his salary and the salary of his best friend.
And here is my task: to distribute the payments so that the maximum upset of any of the ministers turned out to be the minimum possible.
But this task turned out to be too difficult for me. Please help me solve it, otherwise Baitland will be mired in a terrible economic crisis.
Input
The first line contains one number — the total number of ministers.
The second line contains different numbers. The -th number is the number of the minister’s best friend under the number .
The third line contains numbers, where the -th number is the size of the next salary. The size of each salary does not exceed .
Output
The first line should contain the minimum possible maximum disorder of any of the ministers.
The second line should contain numbers separated by a space, where the -th number indicates the amount of salary that was assigned to the -th minister. If there are several optimal salary distributions, output anyone.