#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int main(){
	while(true){
		int w,d,a[21]={},b[21]={};
		cin>>w>>d;
		if(w==0) break;
		rep(i,w){
			int k;
			cin>>k;
			a[k]++;
		}
		rep(i,d){
			int k;
			cin>>k;
			b[k]++;
		}
		int ans=0;
		rep(i,21) ans+=max(a[i],b[i])*i;
		cout<<ans<<endl;
	}
}