#include <bits/stdc++.h>
using namespace std;
int used[100007], n, m, wni[100007], na, used2[100007], vava;
char zaka;
vector<int> a[100007], aftersort;
void topsort(int x) {
  if (na == 1) return;
  if (used[x] == 1) {
    na = 1;
    return;
  }
  if (used[x] == 2) return;
  used[x] = 1;
  int xa;
  xa = a[x].size();
  for (int i = 0; i < xa; i++) topsort(a[x][i]);
  aftersort.push_back(x);
  used[x] = 2;
}
int main() {
  int x, y;
  scanf("%i%i\n", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%i", &wni[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%i", &na);
    for (int j = 1; j <= na; j++) {
      scanf("%i", &vava);
      a[i].push_back(vava);
    }
  }
  na = 0;
  for (int i = 1; i <= m; i++) {
    topsort(wni[i]);
    if (na == 1) {
      cout << -1;
      return 0;
    }
  }
  na = aftersort.size();
  vava = 0;
  for (int i = 0; i < na; i++)
    if (used2[aftersort[i]] == 0) {
      vava++;
      used2[aftersort[i]] = 1;
    }
  cout << vava << endl;
  for (int i = 0; i < na; i++)
    if (used2[aftersort[i]] == 1) {
      printf("%i ", aftersort[i]);
      used2[aftersort[i]] = 2;
    }
}
