#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* constant */

#define MAX_INT (1 << 30)
#define MAX_N   (15)
#define MAX_KEY (14348907)      /* 3 ** 15 */

/* typedef */

typedef char cup_t[MAX_N];

/* global variables */

static int n, m;

static int dists[MAX_KEY];

static int qhead, qtail;
static long q[MAX_KEY];

/* subroutines */

long expi(long d, int n) {
  long e = 1;
  while (n) {
    if (n & 1) e *= d;
    d *= d;
    n >>= 1;
  }
  return e;
}

long arr2key(cup_t cups) {
  int i;
  long key = 0;

  for (i = n - 1; i >= 0; i--)
    key = key * 3 + cups[i];

  return key;
}

char *key2arr(long key, cup_t cups) {
  int i;

  for (i = 0; i < n; i++) {
    cups[i] = key % 3;
    key /= 3;
  }

  return cups;
}

/* main */

int main(int argc, char **argv) {
  int cn, cp, d, dg, g0, g1, i, j, k, nnbr;
  long key, st, u, v;
  static int tops[3];
  static long nbrs[4];
  static cup_t cups, cups0, cups1;

  for (;;) {
    scanf("%d %d", &n, &m);
    if (n == 0 && m == 0) break;

    for (k = 0; k < 3; k++) {
      scanf("%d", &cn);
      for (i = 0; i < cn; i++) {
        scanf("%d", &j);
        cups[j - 1] = k;
      }
    }

    g0 = 0;
    g1 = expi(3, n) - 1;

    st = arr2key(cups);

    for (i = g0; i <= g1; i++)
      dists[i] = MAX_INT;
    dists[st] = 0;

    qhead = 0;
    qtail = 1;
    q[0] = st;

    while (qtail > qhead) {
      u = q[qhead++];

      if (u == g0 || u == g1 || dists[u] >= m) break;

      tops[0] = tops[1] = tops[2] = -1;
      key = u;

      for (i = 0; i < n; i++) {
        cp = key % 3;
        cups0[i] = cp;
        key /= 3;
        tops[cp] = i;
      }

      nnbr = 0;
      if (tops[0] > tops[1]) {
        memcpy(cups1, cups0, sizeof(cup_t));
        cups1[tops[0]] = 1;
        nbrs[nnbr++] = arr2key(cups1);
      }
      if (tops[1] > tops[0]) {
        memcpy(cups1, cups0, sizeof(cup_t));
        cups1[tops[1]] = 0;
        nbrs[nnbr++] = arr2key(cups1);
      }
      if (tops[1] > tops[2]) {
        memcpy(cups1, cups0, sizeof(cup_t));
        cups1[tops[1]] = 2;
        nbrs[nnbr++] = arr2key(cups1);
      }
      if (tops[2] > tops[1]) {
        memcpy(cups1, cups0, sizeof(cup_t));
        cups1[tops[2]] = 1;
        nbrs[nnbr++] = arr2key(cups1);
      }

      d = dists[u] + 1;

      for (i = 0; i < nnbr; i++) {
        v = nbrs[i];
        if (dists[v] > d) {
          dists[v] = d;
          q[qtail++] = v;
        }
      }
    }

    dg = (dists[g0] < dists[g1]) ? dists[g0] : dists[g1];

    printf("%d\n",  dg < MAX_INT ? dg : -1);
  }

  return 0;
}