import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int W, D;
    int[] Hw, Hd;
    bool input() {
        scanf("%d %d\n", &W, &D);
        if (W == 0 && D == 0) return false;
        Hw = readln.chomp.split(" ").map!(to!int).array;
        Hd = readln.chomp.split(" ").map!(to!int).array;
        return true;
    }
    void solve() {
        auto Uw = new bool[W];
        auto Ud = new bool[D];
        int Ans = 0;
        foreach (i; 0 .. W) {
            foreach (j; 0 .. D) {
                if (Uw[i] || Ud[j]) continue;
                if (Hw[i] == Hd[j]) {
                    Uw[i] = Ud[j] = true;
                    Ans += Hw[i];
                }
            }
        }
        foreach (i; 0 .. W) {
            if (!Uw[i]) Ans += Hw[i];
        }
        foreach (i; 0 .. D) {
            if (!Ud[i]) Ans += Hd[i];
        }
        writeln(Ans);
    }
    while (input) solve;
}