#include <bits/stdc++.h>
using namespace std;
const long long N = 100500;
long long vis[N];
long long used[N];
vector<long long> g[N];
vector<long long> ord;
void dfs(long long v) {
  vis[v] = 1;
  for (auto u : g[v]) {
    if (vis[u]) continue;
    dfs(u);
  }
  ord.push_back(v);
}
void chk(long long v) {
  used[v] = 1;
  for (auto u : g[v]) {
    if (used[u] == 1) {
      cout << "-1\n";
      exit(0);
    } else if (!used[u]) {
      chk(u);
    }
  }
  used[v] = 2;
}
void SOLVE() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(k);
  for (long long i = 0; i < k; i++) cin >> a[i], a[i]--;
  for (long long i = 0; i < n; i++) {
    long long tt;
    cin >> tt;
    for (long long j = 0; j < tt; j++) {
      long long x;
      cin >> x;
      x--;
      g[i].push_back(x);
    }
  }
  for (auto now : a) {
    if (!vis[now]) {
      chk(now);
      dfs(now);
    }
  }
  cout << ord.size() << '\n';
  for (auto now : ord) cout << now + 1 << ' ';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout.precision(12);
  long long Q = 1;
  while (Q--) {
    SOLVE();
  }
  return 0;
}
