#include <bits/stdc++.h>
using namespace std;

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

Int state[15000000];

Int f(Int s, Int d, Int c) {
    Int p = s;
    for (Int i = 0; i < d; i++) {
        p /= 3;
    }
    Int x = c -(p % 3);
    for (Int i = 0; i < d; i++) {
        x *= 3;
    }
    return s + x;
}
  
int main() {
    while (true) {
        Int n, m;
        cin >> n >> m;
        if (n == 0) return 0;
        vector<pair<Int, Int>> v;
        for (Int i = 0; i < 3; i++) {
            Int a;
            cin >> a;
            for (Int j = 0; j < a; j++) {
                Int b;
                cin >> b;
                v.emplace_back(b, i);
            }
        }
        sort(all(v));
        Int cur = 0;
        Int x = 1;
        for (Int i = 0; i < n; i++) {
            cur += v[i].se * x;
            x *= 3;
        }
        for (Int i = 0; i < x; i++) {
            state[i] = INF;
        }
        state[cur] = 0;
        queue<Int> q;
        q.push(cur);
        while (not q.empty()) {
            Int s = q.front();
            q.pop();
            Int a, b, c;
            a = b = c = -1;
            Int p = s;
            for (Int i = 0; i < n; i++, p /= 3) {
                if (p % 3 == 0) {
                    a = i;
                }
                else if (p % 3 == 1) {
                    b = i;
                }
                else {
                    c = i;
                }
            }
            //cout << a << " " << b << " " << c << endl;
            if (a != -1 and a > b) {
                Int t = f(s, a, 1);
                if (state[t] > state[s] + 1) {
                    state[t] = state[s] + 1;
                    q.push(t);
                }
            }
            if (b != -1 and b > a) {
                Int t = f(s, b, 0);
                if (state[t] > state[s] + 1) {
                    state[t] = state[s] + 1;
                    q.push(t);
                }
            }
            if (b != -1 and b > c) {
                Int t = f(s, b, 2);
                if (state[t] > state[s] + 1) {
                    state[t] = state[s] + 1;
                    q.push(t);
                }
            }
            if (c != -1 and c > b) {
                Int t = f(s, c, 1);
                if (state[t] > state[s] + 1) {
                    state[t] = state[s] + 1;
                    q.push(t);
                }
            }
        }
        Int all_A = 0;
        Int all_C = x - 1;
        Int res = min(state[all_A], state[all_C]);
        dump(res <= m ? res : -1);
    }
    return 0;
}

