#include <bits/stdc++.h>
using namespace std;
const double Pi{acos(-1.0)};
const int inf{1 << 29}, Mod = 1e9 + 7;
constexpr long long INF{1ll << 60};
long long qpow(long long a, long long b, long long mod = Mod,
               long long ans = 1ll) {
  for (; b; b >>= 1, a = (a * a + mod) % mod)
    if (b & 1) ans = (ans * a + mod) % mod;
  return ans;
}
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); };
long long lcm(long long a, long long b) { return a * b / (gcd(a, b)); }
pair<long long, long long> EXgcd(long long x, long long y) {
  if (!y) {
    return {1, 0};
  }
  pair<long long, long long> a = EXgcd(y, (x + y) % y);
  return {a.second, a.first - a.second * (x / y)};
}
inline bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  return a.first < b.first;
}
const int N = 1e5 + 1;
int ts = 1, n;
vector<int> ans, vis;
vector<vector<int>> G;
bool ok = 1;
void dfs(int x) {
  if (vis[x] > 1 || !ok) return;
  vis[x] = 1;
  for (auto v : G[x]) {
    if (vis[v] == 1) {
      ok = 0;
      break;
    }
    dfs(v);
  }
  vis[x] = 2;
  ans.emplace_back(x);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  while (ts--) {
    int k;
    cin >> n >> k;
    set<int> need;
    vis.resize(n + 1, 0);
    G.resize(n + 1);
    for (int i = 0; i < k; ++i) {
      int x;
      cin >> x;
      need.insert(x);
    }
    for (int i = 1; i <= n; ++i) {
      int j;
      cin >> j;
      while (j--) {
        int v;
        cin >> v;
        G[i].emplace_back(v);
      }
    }
    for (auto i : need) dfs(i);
    if (ok) {
      cout << ans.size() << '\n';
      for (auto i : ans) cout << i << ' ';
    } else
      cout << -1;
    cout << '\n';
  }
}
