#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

int main(){
	int n, m;
	while(cin >> n >> m, n+m){
		int tray[3] = {0};
		rep(ti, 3){
			int ts; cin >> ts;
			rep(i, ts) {
				int num; cin >> num;
				tray[ti] |= 1 << num-1;
			}
		}
		int ans = min(rec(tray[0], tray[1], tray[2]), rec(tray[2], tray[1], tray[0]));
		cout << (ans <= m ? ans : -1) << endl;
	}

	return 0;
}
