#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

int n,m;
ll matome[16];

ll calc(priority_queue<int> &q, int cnt, int pos) {
	//cout << n << "," << cnt << "," << pos << endl;
	if(cnt>=n) return 0;

	cnt++;

	int temp = q.top();q.pop();
	int q_num = (temp>>2)*-1;
	int q_pos = (temp&0b11);

	if(q_pos==pos) {
		return calc(q,cnt,pos);
	}
	if(q_pos==1) {
		return calc(q,cnt,pos^0b10)+1LL+matome[n-cnt-1];
	}else {
		ll rest = calc(q,cnt,pos);
		rest += 2LL + matome[n-cnt-1]*2LL;
		return rest;
	}
}

int main() {
	matome[0] = 2;
	for(int i = 0; i < 15; i++) {
		matome[i+1] = matome[i]*3+2;
	}

	while(true) {
		cin >> n >> m;
		if(n==0) break;

		priority_queue<int> q;
		for(int i = 0; i <= 2; i++) {
			int cnt;
			cin >> cnt;
			for(int j = 0; j < cnt; j++) {
				int cup;
				cin >> cup;
				cup*= -1;
				q.push((cup<<2)|i);
			}
		}
		ll ans = 0;
		{
			int temp = q.top();
			int num = (temp>>2)*-1;
			int pos = (temp&0b11);
			if(pos==0 || pos==2) {
				q.pop();
				ans = calc(q,1,pos);
			}else {
				priority_queue<int> q2(q);
				ll an1 = calc(q,0,0);
				ll an2 = calc(q2,0,2);
				ans = min(an1,an2);
			}
		}
		//cout << ans << endl;
		if(ans<=m) {
			cout << ans << endl;
		}else {
			cout << -1 << endl;
		}
	}
	return 0;
}

