#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int n, m;
int S[3];

int toC(int a, int b, int c) {
	if (!a && !b)return 0;
	if (c & 1)return toC(a >> 1, b >> 1, c >> 1);
	if (b & 1)return toC(c >> 1, b >> 1, a >> 1) + toC((a | b | c) >> 1, 0, 0) + 1;
	if (a & 1)return toC(a >> 1, b >> 1, c >> 1) + 2 * toC((a | b | c) >> 1, 0, 0) + 2;
}

int main(){
	while (scanf("%d%d", &n, &m), n | m){
		rep(i, 3)S[i] = 0;
		rep(t, 3){
			int c;
			scanf("%d", &c);
			rep(i, c){
				int a;
				scanf("%d", &a);
				S[t] |= 1 << a - 1;
			}
		}
		int ans = std::min(toC(S[0], S[1], S[2]), toC(S[2], S[1], S[0]));
		printf("%d\n", ans <= m ? ans : -1);
	}
	return 0;
}