### constant

MAX_H = 20

### main

loop do
  w, d = gets.split.map(&:to_i)
  break if (w | d) == 0

  hxs = gets.split.map(&:to_i)
  hys = gets.split.map(&:to_i)

  hxcs = (MAX_H + 1).times.map{0}
  hycs = (MAX_H + 1).times.map{0}

  hxs.each{|h| hxcs[h] += 1}
  hys.each{|h| hycs[h] += 1}

  count = 0
  for h in (1..MAX_H)
    count += ((hxcs[h] > hycs[h]) ? hxcs[h] : hycs[h]) * h
  end
  p count
end