#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

#define Int long long


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	Int n, m;

	while (cin >> n >> m, n) {
		auto encode = [n](auto &v) {
			Int x = 0;
			for (Int i = 0; i < n; i++) x = x * 3 + v[i];
			return x;
		};

		auto decode = [n](Int x) {
			vector<Int> v(n);
			for (Int i = 0; i < n; i++) {
				v[n - (i + 1)] = x % 3;
				x /= 3;
			}
			return v;
		};

		vector<Int> dp(14348907, -1);

		queue<Int> q;
		for (Int i = 0; i < 2; i++) {
			vector<Int> b(n, i * 2);
			Int k = encode(b);
			dp[k] = 0;
			q.emplace(k);
		}

		while (!q.empty()) {
			Int k = q.front();
			vector<Int> v = decode(k); q.pop();
			vector<Int> x(3, -1);
			for (Int i = 0; i < n; i++) x[v[i]] = i;
			for (Int i = 0; i < 3; i++) {
				for (Int j = 0; j < 3; j++) {
					if (i == j || abs(i - j) == 2) continue;
					if (x[i] > x[j]) {
						v[x[i]] = j;
						Int nk = encode(v);
						if (dp[nk] < 0) {
							dp[nk] = dp[k] + 1;
							q.emplace(nk);
						}
						v[x[i]] = i;
					}
				}
			}
		}

		vector<Int> v(n);
		for (Int i = 0; i < 3; i++) {
			Int k;
			cin >> k;
			for (Int j = 0; j < k; j++) {
				Int x;
				cin >> x;
				v[x - 1] = i;
			}
		}
		Int k = encode(v);
		//cout<<k<<":"<<dp[k]<<endl;
		cout << (dp[k] > m ? -1 : dp[k]) << endl;
	}
	return 0;
}


Measured memory_bytes: 115004