w,d,c,i,q,r[21],s[21];main(){while(1){scanf("%d%d",&w,&d);if(!w&&!d){return 0;}for(;w--;){scanf("%d",&c);r[c]++;}for(;d--;){scanf("%d",&c);s[c]++;}for(;i<21;i++){q+=(r[i]>s[i]?r[i]:s[i])*i;}printf("%d\n",q);}}