An artwork is a collection of unit cubes (each edge one foot long) piled up on flat ground that is divided into a grid of one-foot squares. A cube must either sit on the ground inside one grid square, or rest squarely on top of another cube so that the bottom face of the upper cube exactly meets the top face of the lower one. No other placement is allowed.
The ground grid has $w$ columns and $d$ rows, so the cubes form piles on a $w \times d$ grid. A design is described by two views:
Many different arrangements of cubes can produce the same pair of views, and they may use different numbers of cubes. Because the installation cost is proportional to the number of cubes, you must determine, for a given front view and side view, the minimum number of unit cubes that realizes both views at the same time.
Swapping two columns does not change the side view, and swapping two rows does not change the front view, so such swaps never change the cost.
The input is a sequence of datasets. It ends with a line containing two zeros separated by a space. Each dataset has the form
w d
h1 h2 ... hw h'1 h'2 ... h'd
The first line gives the grid width $w$ and depth $d$. The second line lists $w$ integers $h_1, \dots, h_w$ — the front-view heights of the columns — followed by $d$ integers $h'_1, \dots, h'_d$ — the side-view heights of the rows.
You may assume that every dataset can be realized by at least one arrangement of cubes.
For each dataset, output a single line containing the minimum number of cubes needed. The line must contain nothing else.