#include <bits/stdc++.h>
using namespace std;
double eps = (double)1 / 1e6;
long long inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
long long sqr(long long a) { return a * a; }
long long qb(long long a) { return a * a * a; }
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
long long binpow(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod
                    : sqr(binpow(a, b / 2, mod)) % mod)
           : 1;
}
long long binmult(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod
                    : (2 * binmult(a, b / 2, mod)) % mod)
           : 0;
}
const long long R = 1e4;
const long long to[7] = {1, 2, 3, 1, 3, 2, 1};
const long long N = 3 * 1e5;
vector<long long> g[N];
long long tin[N], tout[N];
long long timer = 0;
vector<long long> ans;
void dfs(long long v) {
  tin[v] = ++timer;
  for (auto u : g[v]) {
    if (!tin[u]) {
      dfs(u);
    } else {
      if (tin[u] < tin[v] && !tout[u]) {
        cout << -1;
        exit(0);
      }
    }
  }
  tout[v] = ++timer;
  ans.push_back(v);
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m);
  for (auto &z : a) {
    cin >> z;
    --z;
  }
  long long v, u;
  for (long long i = 0; i < n; i++) {
    long long col;
    cin >> col;
    for (long long j = 0; j < col; j++) {
      cin >> u;
      --u;
      g[i].push_back(u);
    }
  }
  for (auto z : a) {
    if (!tin[z]) {
      dfs(z);
    }
  }
  cout << (int)ans.size() << "\n";
  for (auto z : ans) cout << z + 1 << " ";
  return 0;
}
