#include <bits/stdc++.h>
using namespace std;
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define rep(i,n) for(int i=0;i<n;i++)
#define geti(...) int __VA_ARGS__;bulk(__VA_ARGS__)
using vi=vector<int>;
int main(void){
    int m,n;
    while(cin>>m>>n,m){
        vector<vi> mp(21,vi(2,0));
        rep(i,m){
            geti(p);
            mp[p][0]+=p;
        }
        rep(i,n){
            geti(p);
            mp[p][1]+=p;
        }
        int ans=0;
        rep(i,21)
            ans+=max(mp[i][0],mp[i][1]);
        cout<<ans<<endl;
    }
}