#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const long long MAX_N = 1e5 + 5;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;
vector<int> son[MAX_N];
bool used[MAX_N];
bool now[MAX_N];
int ans[MAX_N];
int need[MAX_N];
int tot = 0;
int dfs(int x) {
  if (used[x]) return 0;
  if (now[x]) return 1;
  now[x] = true;
  for (auto i : son[x]) {
    if (dfs(i)) return 1;
  }
  now[x] = false;
  ans[++tot] = x;
  used[x] = true;
  return 0;
}
int main() {
  int n, k;
  cin >> n >> k;
  memset(used, false, sizeof(used));
  memset(now, false, sizeof(now));
  for (int i = 1; i <= k; ++i) {
    scanf("%d", &need[i]);
  }
  int m, x;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &m);
    while (m--) {
      scanf("%d", &x);
      son[i].push_back(x);
    }
  }
  bool flag = true;
  for (int i = 1; i <= k; ++i) {
    if (used[need[i]]) continue;
    if (dfs(need[i])) {
      flag = false;
      break;
    }
  }
  if (flag) {
    printf("%d\n", tot);
    for (int i = 1; i < tot; ++i) {
      printf("%d ", ans[i]);
    }
    printf("%d\n", ans[tot]);
  } else {
    printf("-1\n");
  }
  return 0;
}
