using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public int[] InitPos, Goal1, Goal2;
        public long HashGoal1, HashGoal2;
        public int[] InitMx;
        public HashSet<long> Used;
        public int ret;
        public void Run()
        {
            while (true)
            {
                {
                    var line = Input.ReadIntArray();
                    N = line[0];
                    M = line[1];
                }

                if (N == 0 && M == 0) return;
                InitPos = new int[N];

                for (int i = 0; i < 3; i++)
                {
                    var line = Input.ReadIntArray().Skip(1).Select(e => e - 1);
                    foreach (var e in line)
                    {
                        InitPos[e] = i;
                    }
                }

                InitMx = MX(InitPos);

                Goal1 = new int[N];
                Goal2 = new int[N];
                for (int i = 0; i < N; i++)
                {
                    Goal1[i] = 0;
                    Goal2[i] = 2;
                }

                HashGoal1 = Hash(Goal1);
                HashGoal2 = Hash(Goal2);

                ret = -1;
                BFS(InitPos, InitMx);

                Console.WriteLine(ret);
            }
         
        }

        public void BFS(int[] pos, int[] mx)
        {
            Used = new HashSet<long>();

            var queue = new Queue<Data>();
            queue.Enqueue(new Data { dist = 0, pos = pos, mx=mx });
            while (queue.Count > 0)
            {
                var d = queue.Dequeue();
                var hash = Hash(d.pos);

                // Check
                if (d.dist > M) continue;
                if (Used.Contains(hash)) continue;
                Used.Add(hash);
               

                // Check Goal
                if (hash == HashGoal1 || hash == HashGoal2)
                {
                    ret = d.dist;
                    break;
                }

                // Move
                // Console.Error.WriteLine(string.Join(", ", d.pos) + " - " + string.Join(", ", d.mx));
                
                if (d.mx[0] < d.mx[1])
                {
                    var p = d.pos.ToArray();
                    p[d.mx[1]] = 0;
                    queue.Enqueue(new Data {dist = d.dist + 1, pos = p, mx = MX(p)});
                }
                else
                {
                    var p = d.pos.ToArray();
                    p[d.mx[0]] = 1;
                    queue.Enqueue(new Data { dist = d.dist + 1, pos = p, mx = MX(p) });
                }

                if (d.mx[1] < d.mx[2])
                {
                    var p = d.pos.ToArray();
                    p[d.mx[2]] = 1;
                    queue.Enqueue(new Data { dist = d.dist + 1, pos = p, mx = MX(p) });
                }
                else
                {
                    var p = d.pos.ToArray();
                    p[d.mx[1]] = 2;
                    queue.Enqueue(new Data { dist = d.dist + 1, pos = p, mx = MX(p) });
                }
            }
        }

        public long Hash(int[] pos)
        {
            long m = 1;
            long ret = 0;
            for (int i = 0; i < pos.Length; i++)
            {
                ret += m * pos[i];
                m *= 3;
            }
            return ret;
        }

        public int[] MX(int[] pos)
        {
            int[] ret = new int[3];
            for (int i = 0; i < 3; i++)
            {
                ret[i] = -1;
            }
            for (int i = 0; i < pos.Length; i++)
            {
                ret[pos[i]] = i;
            }
            return ret;
        }
    }

    // libs ----------
    class Data
    {
        public int dist;
        public int[] pos;
        public int[] mx;
    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 127616