### constant

MAX_INT = 1 << 30

### subroutines

def arr2key(arr)
  key = 0
  ($n - 1).downto(0) do |i|
    key = key * 3 + arr[i]
  end
  key
end

def key2arr(key)
  arr = []
  for i in (0...$n)
    arr << key % 3
    key /= 3
  end
  arr
end

### main

loop do
  $n, $m = gets.strip.split(' ').map{|s| s.to_i}
  break if $n == 0 && $m == 0

  ta = gets.strip.split(' ').map{|s| s.to_i}
  tb = gets.strip.split(' ').map{|s| s.to_i}
  tc = gets.strip.split(' ').map{|s| s.to_i}

  nta = ta.shift
  ntb = tb.shift
  ntc = tc.shift

  cups = []
  ta.each{|c| cups[c - 1] = 0}
  tb.each{|c| cups[c - 1] = 1}
  tc.each{|c| cups[c - 1] = 2}
  # p cups

  g0 = 0
  g1 = (3 ** $n) - 1

  st = arr2key(cups)

  dists = (g0..g1).map{MAX_INT}
  dists[st] = 0

  q = [st]

  while ! q.empty?
    u = q.shift
    next if u == g0 || u == g1 || dists[u] >= $m

    tops = [-1, -1, -1]
    cups0 = []
    key = u
    for i in (0...$n)
      cp = key % 3
      cups0 << cp
      key /= 3
      tops[cp] = i
    end
    #p tops

    nbrs = []
    if tops[0] > tops[1]
      cups1 = cups0.clone
      cups1[tops[0]] = 1
      nbrs << arr2key(cups1)
    end
    if tops[1] > tops[0]
      cups1 = cups0.clone
      cups1[tops[1]] = 0
      nbrs << arr2key(cups1)
    end
    if tops[1] > tops[2]
      cups1 = cups0.clone
      cups1[tops[1]] = 2
      nbrs << arr2key(cups1)
    end
    if tops[2] > tops[1]
      cups1 = cups0.clone
      cups1[tops[2]] = 1
      nbrs << arr2key(cups1)
    end

    d = dists[u] + 1

    for v in nbrs
      if dists[v] > d
        dists[v] = d
        q << v
      end
    end
  end

  dg = [dists[g0], dists[g1]].min

  puts (dg < MAX_INT ? dg : -1)
end