#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using S = int;

int encode(int a, int c, int n)
{
    int b = ((1 << n) - 1) ^ (a | c);
    int result = 0;
    rrep(i, n)
    {
        result *= 3;
        if ((c >> i) & 1) {
            result += 2;
        }
        if ((b >> i) & 1) {
            result += 1;
        }
        if ((a >> i) & 1) {
            result += 0;
        }
    }
    return result;
}

tuple<int, int, int> decode(int k, int n)
{
    int a, b, c;
    a = b = c = 0;

    rep(i, n)
    {
        int r = k % 3;
        if (r == 2) {
            c |= (1 << i);
        }
        if (r == 1) {
            b |= (1 << i);
        }
        if (r == 0) {
            a |= (1 << i);
        }
        k /= 3;
    }

    return make_tuple(a, b, c);
}

int msb(int x)
{
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;
    return (x >> 1) + 1;
}

const int SMAX = 14348907;
int dist[SMAX];

void solve(int n, int m)
{
    S sa = 0, sc = 0;
    int an, bn, cn;
    cin >> an;
    rep(i, an)
    {
        int a;
        cin >> a;
        a--;
        sa |= (1 << a);
    }
    cin >> bn;
    rep(i, bn)
    {
        int b;
        cin >> b;
    }
    cin >> cn;
    rep(i, cn)
    {
        int c;
        cin >> c;
        c--;
        sc |= (1 << c);
    }

    fill(dist, dist + SMAX, -1);
    queue<S> q;
    dist[encode(sa, sc, n)] = 0;
    q.push(encode(sa, sc, n));

    while (!q.empty()) {
        int s = q.front();
        q.pop();

        int d = dist[s];
        if (d >= m) {
            break;
        }

        int a, b, c;
        tie(a, b, c) = decode(s, n);

        if (a > b) {
            int na = a & ~msb(a), nb = b | msb(a), nc = c;
            int key = encode(na, nc, n);
            if (dist[key] < 0) {
                dist[key] = d + 1;
                q.push(key);
            }
        }
        if (a < b) {
            int na = a | msb(b), nb = b & ~msb(b), nc = c;
            int key = encode(na, nc, n);
            if (dist[key] < 0) {
                dist[key] = d + 1;
                q.push(key);
            }
        }
        if (b > c) {
            int na = a, nb = b & ~msb(b), nc = c | msb(b);
            int key = encode(na, nc, n);
            if (dist[key] < 0) {
                dist[key] = d + 1;
                q.push(key);
            }
        }
        if (b < c) {
            int na = a, nb = b | msb(c), nc = c & ~msb(c);
            int key = encode(na, nc, n);
            if (dist[key] < 0) {
                dist[key] = d + 1;
                q.push(key);
            }
        }
    }

    int e1 = encode((1 << n) - 1, 0, n), e2 = encode(0, (1 << n) - 1, n);
    int result = m + 1;
    if (dist[e1] >= 0) {
        result = min(result, dist[e1]);
    }
    if (dist[e2] >= 0) {
        result = min(result, dist[e2]);
    }

    cout << (result > m ? -1 : result) << endl;
}

int main()
{
    int n, m;
    cin >> n >> m;
    while (n != 0 || m != 0) {
        solve(n, m);
        cin >> n >> m;
    }

    return 0;
}


Measured memory_bytes: 59120