#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define min(a, b) (a > b ? b : a)

int func(int a, int b, int c) {
    if (b == 0 && c == 0)
        return 0;
    else if (a & 1)
        return func(a >> 1, b >> 1, c >> 1);
    else if (b & 1)
        return func(c >> 1, b >> 1, a >> 1) + 1 + func(0, 0, (a | b | c) >> 1);
    else
        return func(a >> 1, b >> 1, c >> 1) + 1 + func(0, (a | b | c) >> 1, 0) +
               func(0, a | b | c, 0);
}

int main() {
    int n, m, tray[3];
    while (std::cin >> n >> m && n && m) {
        rep(i, 3) {
            tray[i] = 0;
            int k, num;
            std::cin >> k;
            rep(j, k) {
                std::cin >> num;
                tray[i] |= 1 << (num - 1);
            }
        }

        int res = min(func(tray[0], tray[1], tray[2]),
                      func(tray[2], tray[1], tray[0]));
        std::cout << (res <= m ? res : -1) << std::endl;
    }
}