This problem will only be considered to distinguish between contestants whose scores are otherwise equal. You should ensure that you've got as many marks as possible in the other problems before attempting this one.
None of the test data will be seen, and there are no marks for producing an output file.
Otherwise this problem is the same as the others; you must save your program as 'day2d.ext' where ext is the extension (PAS, C, CPP or BC, BAS). Your program should read its input from a file called day2d.dat and write the solution to a file called day2d.sol.
A construction is a number of cubes arranged on a square base as in the diagram below.

This is a four by four square supporting stacks of cubes. No stack will contain more than 8 cubes. The front and side projections of the construction are shown below.
![]() |
|
| Front | Side |
Obviously there are a number of constructions that will satisfy both these projections. The constructions with the maximum and minimum number of blocks that will satisfy both projections are shown below.

Here the maximum number of blocks is 17, and the minimum is 7. Your job is to find the maximum and minimum number of blocks given the front and side projections.
The first line contains k, (1 <= k <= 8), the length of the side of the square base. The next two lines contain descriptions of the construction (the front projection followed by the side projection). Each description consists of k integers. Each integer indicates the height of the corresponding projection of a stack of blocks.
The output will be one line containing the maximum number of blocks followed by a line containing the minimum number of blocks.
Input
4 2 0 3 1 1 1 2 3
Output
17 7
Input
1 1 1
Output
1 1