#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int W, D;
int H1[15], H2[15];

void read();
void solve();

int main() {
  while (cin >> W >> D, W != 0 && D != 0)
    read(), solve();

  return 0;
}

void read() {
  for (int i = 0; i < W; ++i)
    cin >> H1[i];
  for (int i = 0; i < D; ++i)
    cin >> H2[i];
}

void solve() {
  static int c1[25], c2[25];

  fill(&c1[0], &c1[25], 0);
  fill(&c2[0], &c2[25], 0);
  for (int i = 0; i < W; ++i)
    c1[H1[i]] += H1[i];
  for (int i = 0; i < D; ++i)
    c2[H2[i]] += H2[i];

  int res = 0;

  for (int i = 1; i <= 20; ++i) {
    int m = min(c1[i], c2[i]);
    res += m, c1[i] -= m, c2[i] -= m;
  }

  res += accumulate(&c1[0], &c1[25], 0);
  res += accumulate(&c2[0], &c2[25], 0);

  cout << res << "\n";
}