#include <iostream>
#include <cstring>
#include <map>
#include <vector>
#include <tr1/unordered_map>
using namespace std;

int n;

int goal = 0;

typedef int P ;
#define HASH_VAL 113341
unsigned int f(int n,unsigned int size){
	return n%HASH_VAL ;
}
template <class K, class V>  
class hashMap {  
    static const unsigned int DEFAULT_SIZE = HASH_VAL ;  
    vector<pair<K, V> > *contents;  
    unsigned int _size;  
    unsigned int (*_hashValue) (K, unsigned int);  
  
public:  
    hashMap(unsigned int (*func) (K, unsigned int) , unsigned int size = DEFAULT_SIZE) {  
        _hashValue = func;  
        _size = size;  
        contents = new vector<pair<K, V> > [_size];  
    }  
  
    ~hashMap() {  
        delete [] contents;  
    }  
  
    bool hashElement(K s) {  
        unsigned int h = _hashValue(s, _size);  
  
        for (int i = 0; i < (int)contents[h].size(); i++) {  
            if (contents[h][i].first == s)  
                return true;  
        }  
  
        return false;  
    }  
  
    void insert(K x, V n) {  
        if (hashElement(x))  
            return;  
  
        unsigned int h = _hashValue(x, _size);  
        contents[h].push_back(make_pair(x, n));  
    }  
  
    pair<K, V> *getElement(K x) {  
        unsigned int h = _hashValue(x, _size);  
        for (int i = 0; i < (int)contents[h].size(); i++)  
            if (contents[h][i].first == x)  
                return &contents[h][i];  
  
        return NULL;  
    }  
  
    void printHashBalance() {  
        int cnt = 0;  
        double ret = 0.0;  
        int worst = 0;  
  
        for (int i = 0; i < (int)_size; i++) {  
            if (contents[i].size()) {  
                ++cnt;  
                ret += contents[i].size();  
                worst = max<int>(worst, contents[i].size());  
            }  
        }  
  
        if (!cnt)  
            cerr << "Hash is empty" << endl;  
        else {  
            cerr << "collisions occurred(average): " << (ret/cnt) << endl;  
            cerr << "collisions occurred(worst): " << worst << endl;  
        }  
    }  
};  

P Q[30];
int m,stat,tim,head,size,i,t,a,j,from,to,next;

int main(){
	while(cin >> n >> m && n){
		hashMap<int,int> done(&f);
		int init = 0;
		for(i = 0 ; i < n ; i++) goal |= 2 << (i*2);
		
		for(i = 0 ; i < 3 ; i++){
			t,a; cin >> t;
			while(t--){cin >> a; a--; init |= (i) << (2*a); }
		}
		head = 0 , size = 0;
		Q[size++] = init;
		done.insert(init,0);
		int hoge = 0;
		while(head != size){
			hoge++;
			stat = Q[head++];
			tim = (*done.getElement(stat)).second;
			if(tim > m) break;
			if(stat == goal || stat == 0){ cout << tim << endl; goto hoge;}
			int mi[3] = {-1,-1,-1};
			for(i = n-1 ; i >= 0 ; i--){
				int num = stat>>(i*2)&3;
				if(mi[num]==-1)mi[num] = i;
			}
			
			for(from = 0 ; from < 3 ; from++){
				for(to = 0 ; to < 3 ; to++){
					if ( !( (from == 0 && to == 2) || (from == 2 && to == 0) ) && from != to && mi[from] != -1 && (mi[to] == -1 || mi[from] > mi[to]) ){
						next = (stat & ~(3<<(2*mi[from]))) | (to<<(2*mi[from]));
						if(done.getElement(next)==NULL)Q[size++] = next , done.insert(next,tim+1);
						head %= 30;
						size %= 30;
					}
				}
			}
		}
		cout << -1 << endl;
		hoge:;
		//done.printHashBalance();
	}
}

Measured memory_bytes: 32000