#include <bits/stdc++.h>
using namespace std;
int n, k, v[100005], t, x, l[100005], K;
short p[100005];
vector<int> a[100005];
bitset<100005> w;
stack<int> st;
void dfs(int nod) {
  w[nod] = 1;
  vector<int>::iterator it;
  for (it = a[nod].begin(); it != a[nod].end(); ++it)
    if (!w[*it]) dfs(*it);
  l[++K] = nod;
}
void dfs1(int nod) {
  p[nod] = 1;
  vector<int>::iterator it;
  for (it = a[nod].begin(); it != a[nod].end(); ++it)
    if (!p[*it])
      dfs1(*it);
    else if (p[*it] == 1) {
      cout << "-1";
      exit(0);
    }
  p[nod] = 2;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) cin >> v[i];
  for (int i = 1; i <= n; ++i) {
    cin >> t;
    for (int j = 1; j <= t; ++j) cin >> x, a[i].push_back(x);
  }
  for (int i = 1; i <= k; ++i) dfs1(v[i]);
  for (int i = 1; i <= k; ++i)
    if (!w[v[i]]) dfs(v[i]);
  cout << K << '\n';
  for (int i = 1; i <= K; ++i) cout << l[i] << " ";
  return 0;
}
