1998 was the first year the Central Europe Regional Contest was held in Prague, at the Czech Technical University. That meant three programming contests in one year. It was also the year a new evaluation system, PCSS 3, was written from scratch. The program then ran with only small improvements and bug fixes for the next 14 years, until 2011. A typical contest in 1998 had 20 teams and 6 problems, and the best computer available had 64MB of memory, so PCSS had to impose many limits on its data structures. By 2011 there were about 100 teams and 11 problems, so most of those limits had been exceeded several times over during those 14 years.
Now you get to visit the past and solve one of the 1998 problems.
Little Matthew always wanted to be an architect, and since childhood he spent his free time building architectonic masterpieces. His resources were limited, so he built from wooden unit cubes stacked on top of each other. He always placed the columns of cubes on a checkerboard of K×K unit squares, and every column covered exactly one square of the board.
Once a building was finished, Matthew drew two pictures of it: the view from the front and the view from the right. The front drawing records, from left to right, the height of the tallest column in each column of the board. The right drawing records, from front to back, the height of the tallest column in each row of the board.
Matthew believed the two drawings would be enough to reconstruct the building later. Only as an adult did he realize he had been wrong. Most of his pairs of drawings can depict many different buildings. He therefore called a building minimal when it uses the smallest number L of cubes among all buildings whose pair of projections matches the drawings, and maximal when it uses the largest number M of cubes among all such buildings.
Given a pair of drawings, write a program that computes L and M.
The first line contains the number of test cases N. Each test case is three lines. The first line of a test case contains a positive integer K, the width and the height of the square board, with K≤100. The second line describes the drawing from the front and the third line describes the drawing from the right. Each drawing is given as K space separated non-negative integers, none of them larger than 100000. The front drawing gives the heights of the K projected columns in left to right order, the right drawing in front to back order.
You can assume that at least one building can be built for every given pair of drawings.
For each test case, print exactly one line:
Minimalni budova obsahuje L kostek, maximalni M kostek.
Here L is the minimal and M the maximal number of cubes in a building represented by the given pair of drawings.