{"trustable":false,"sections":[{"title":"Description","value":{"format":"HTML","content":"\u003cdiv\u003e\n\u003cp\u003e让我们再把视线聚焦回\u003ci\u003eMiss Tang\u003c/i\u003e和\u003ci\u003eSidney\u003c/i\u003e哈。\u003ci\u003eMiss Tang\u003c/i\u003e作为一个有爱的小姐姐炒鸡喜欢搭积木,她一般会照着给出的一个正视图和侧视图搭。具体规则如下:使用等大的正方体搭积木,可以把一块搭在另一块上,或者直接放在地上。现在给出正视图和侧视图,\u003ci\u003eSidney\u003c/i\u003e该发愁最少要买多少个正方体才可以组成这样的图形。\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input is a sequence of datasets. The end of the input is indicated by a line containing two zeros separated by a space. Each dataset is formatted as follows.\n\u003cpre\u003ew d\nh1 h2 ... hw\nh′1 h′2 ... h′d\u003c/pre\u003e\nThe integers w and d separated by a space are the numbers of columns and rows of the grid, respectively. You may assume 1 ≤ w ≤ 10 and 1 ≤ d ≤ 10. The integers separated by a space in the second and third lines specify the shape of the artwork. The integers hi (1 ≤ hi ≤ 20,1 ≤ i ≤ w) in the second line give the front view, i.e., the maximum heights of cubes per each column line, ordered from left to right (seen from the front). The integers h′ i (1 ≤ h′ i ≤ 20,1 ≤ i ≤ d) in the third line give the side view, i.e., the maximum heights of cubes per each row line, ordered from left to right (seen from the right-hand side). "}},{"title":"Output","value":{"format":"HTML","content":"For each dataset, output a line containing the minimum number of cubes. The output should not contain any other extra characters. You can assume that, for each dataset, there is at least one way to install the artwork. "}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e5 5\n1 2 3 4 5\n1 2 3 4 5\n5 5\n2 5 4 1 3\n4 1 5 3 2\n5 5\n1 2 3 4 5\n3 3 3 4 5\n3 3\n7 7 7\n7 7 7\n3 3\n4 4 4\n4 3 4\n4 3\n4 2 2 4\n4 2 1\n4 4\n2 8 8 8\n2 3 8 3\n10 10\n9 9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9 9\n10 9\n20 1 20 20 20 20 20 18 20 20\n20 20 20 20 7 20 20 20 20\n0 0\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e15\n15\n21\n21\n15\n13\n32\n90\n186\n\u003c/pre\u003e"}}]}