#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int viz[MAXN];
vector<int> gr[MAXN];
int need[MAXN];
vector<int> sol;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; ++i) scanf("%d", need + i);
  for (int i = 1; i <= n; ++i) {
    int hm;
    scanf("%d", &hm);
    while (hm--) {
      int x;
      scanf("%d", &x);
      gr[i].emplace_back(x);
    }
  }
  function<void(int)> dfs = [&](int node) {
    viz[node] = 2;
    for (auto &x : gr[node]) {
      if (viz[x] == 2) {
        puts("-1");
        exit(0);
      }
      if (viz[x]) continue;
      dfs(x);
    }
    sol.emplace_back(node);
    viz[node] = 1;
    return;
  };
  for (int i = 0; i < k; ++i) {
    if (!viz[need[i]]) dfs(need[i]);
  }
  printf("%d\n", sol.size());
  for (auto &x : sol) {
    printf("%d ", x);
  }
}
