#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

unsigned f(unsigned S, int x, int from, int to) {
  if (from >= 0) {
    S &= ~((from >> 0 & 1) << (x << 1));
    S &= ~((from >> 1 & 1) << ((x << 1) + 1));
  }
  S |= (to >> 0 & 1) << (x << 1);
  S |= (to >> 1 & 1) << ((x << 1) + 1);
  return S;
}

vector<int> getTop(unsigned S, int n) {
  vector<int> res(3, -1);
  for (int i = 0; i < n; i++) {
    int l = S >> ((i << 1) + 1) & 1;
    int r = S >> (i << 1) & 1;
    res[(l << 1) + r] = max(res[(l << 1) + r], i);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n, m;
  while (cin >> n >> m, n) {
    unsigned S = 0;
    for (int i = 0; i < 3; i++) {
      int sz;
      cin >> sz;
      for (int j = 0; j < sz; j++) {
        int x;
        cin >> x;
        S = f(S, x - 1, -1, i);
      }
    }

    map<unsigned, int> d;
    d[S] = 0;
    queue<unsigned> que;
    que.emplace(S);
    int ans = -1;
    while (que.size()) {
      unsigned s = que.front(); que.pop();
      auto v = getTop(s, n);
      if (v[1] < 0 && (v[0] < 0 || v[2] < 0)) {
        ans = (d[s] <= m ? d[s] : -1);
        break;
      }
      
      unsigned ns;
      for (int i = 0; i < 3; i++) {
        int l = i == 0 ? -1 : i - 1;
        int r = i == 2 ? -1 : i + 1;
        if (l >= 0 && v[i] > v[l]) {
          ns = f(s, v[i], i, l);
          if (d.find(ns) == d.end()) {
            d[ns] = d[s] + 1;
            que.emplace(ns);
          }
        }
        if (r >= 0 && v[i] > v[r]) {
          ns = f(s, v[i], i, r);
          if (d.find(ns) == d.end()) {
            d[ns] = d[s] + 1;
            que.emplace(ns);
          }
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
