#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int n, m;
	
	long long int a[20] = {};
	for(int i = 1; i < 20; i++){
		a[i] = a[i - 1] * 3 + 2;
	}
	
	while(true){
		cin >> n >> m;
		if(n == 0){
			break;
		}
		int tile[20] = {};
		for(int loop = 0; loop < 3; loop++){
			int num;
			cin >> num;
			for(int i = 0; i < num; i++){
				int num2;
				cin >> num2;
				num2 = n - num2 + 1;
				tile[num2] = loop;
			}
		}
		tile[0] = 10000;
		tile[n + 1] = 0;
		long long int ans = 1000000000LL;
		
		long long int cnt = 0;
		for(int i = 1; i <= n; i++){
			if(abs(tile[i] - tile[i + 1]) == 1){
				if(tile[i] - tile[i + 1] != tile[i - 1] - tile[i] && tile[i + 1] != 1){
					cnt += a[i] / 2;
				}else{
					cnt *= -1;
					cnt += a[i] / 2;
				}
			}else if(abs(tile[i] - tile[i + 1]) == 2){
				cnt *= -1;
				cnt += a[i];
			}else if(tile[i] == 1){
				cnt *= -1;
			}
			//cout << cnt << " ";
		}
		//cout << cnt << endl;
		ans = min(ans, cnt);
		
		tile[n + 1] = 2;
		
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(abs(tile[i] - tile[i + 1]) == 1){
				if(tile[i] - tile[i + 1] != tile[i - 1] - tile[i] && tile[i + 1] != 1){
					cnt += a[i] / 2;
				}else{
					cnt *= -1;
					cnt += a[i] / 2;
				}
			}else if(abs(tile[i] - tile[i + 1]) == 2){
				cnt *= -1;
				cnt += a[i];
			}else if(tile[i] == 1){
				cnt *= -1;
			}
			//cout << cnt << " ";
		}
		//cout << cnt << endl;
		ans = min(ans, cnt);
		if(ans > m){
			cout << "-1" << endl;
		}else{
			cout << ans << endl;
		}
	}
	
	return 0;
}

