#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
vector<int> vv;
int st[100005];
int u[100005];
int n, k;
bool dfs(int v) {
  u[v] = 1;
  for (int to : adj[v]) {
    if (u[to] == 0) {
      if (dfs(to)) {
        return 1;
      }
    } else if (u[to] == 1) {
      return 1;
    }
  }
  vv.push_back(v);
  u[v] = 2;
  return 0;
}
void solve() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= k; ++i) {
    scanf("%d", &st[i]);
  }
  for (int i = 1, x, v; i <= n; ++i) {
    scanf("%d", &x);
    while (x--) {
      scanf("%d", &v);
      adj[i].push_back(v);
    }
  }
  for (int i = 1; i <= k; ++i) {
    if (u[st[i]]) {
      continue;
    }
    if (dfs(st[i])) {
      printf("-1\n");
      return;
    }
  }
  printf("%d\n", vv.size());
  for (int it : vv) {
    printf("%d ", it);
  }
  printf("\n");
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
