P18038 [UKIEPC 2020] Moderate Pace

Description

Ultramarathons are long races, often taking five hours or even longer. You and two other ultramarathon runners have formed a team, hoping to get a good result in this year's long north-to-south run from Plymouth to Aberdeen. There is a fixed number of days left to train before the next race. For safety, the three of you train together every day. However, each of you has your own plan for how many kilometers to run each day, so you have to compromise with each other. The fairest way is to consider each day separately and take the median of the three planned distances for that day. That is, the distance chosen for a day must not be larger than both of the other two distances, nor smaller than both of them.

Input Format

- The first line contains an integer $n$ ($1\leq n\leq 1000$), the number of training days. - The second line contains $n$ integers $k_1,\ldots,k_n$ ($0\leq k_i\leq 10^6$), your ideal daily running distances. - The third line contains $n$ integers $a_1,\ldots,a_n$ ($0\leq a_i\leq 10^6$), the ideal daily running distances of the first teammate. - The fourth line contains $n$ integers $b_1,\ldots,b_n$ ($0\leq b_i\leq 10^6$), the ideal daily running distances of the second teammate.

Output Format

Output $n$ integers representing the training plan, where the running distance of each day is the median of the three planned distances for that day.

Explanation/Hint

Translated by QwenWork