#include <bits/stdc++.h>
using namespace std;
vector<long long> sub, ans;
vector<long long> vis;
vector<vector<long long> > adj;
bool ok = true;
void dfs(long long cur) {
  if (vis[cur] == 0) {
    vis[cur]++;
    for (auto x : adj[cur]) dfs(x);
    vis[cur] = 2;
    ans.push_back(cur);
  } else if (vis[cur] == 1) {
    ok = false;
    return;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vis.resize(n + 1, 0);
  for (long long i = 0; i < k; i++) {
    long long a;
    cin >> a;
    sub.push_back(a);
  }
  adj.resize(n + 1);
  for (long long i = 1; i <= n; i++) {
    long long b, c;
    cin >> b;
    while (b--) {
      cin >> c;
      adj[i].push_back(c);
    }
  }
  for (long long i = 0; i < k; i++) {
    if (!vis[sub[i]]) {
      ok = true;
      dfs(sub[i]);
      if (ok == false) break;
    }
  }
  if (ok) {
    cout << ans.size() << endl;
    for (auto x : ans) cout << x << " ";
  } else {
    cout << "-1";
  }
  return 0;
}
