#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj(100001);
vector<int> vis(100001, 0);
vector<int> sol;
int ans = 0;
void dfs(int k) {
  if (vis[k]) {
    return;
  }
  vis[k] = 1;
  ans++;
  for (auto j : adj[k]) {
    dfs(j);
  }
  sol.push_back(k);
  return;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> sn(k);
  for (int i = 0; i < k; i++) {
    cin >> sn[i];
  }
  for (int i = 1; i <= n; i++) {
    int h;
    cin >> h;
    while (h--) {
      int l;
      cin >> l;
      adj[i].push_back(l);
    }
  }
  for (int i = 0; i < sn.size(); i++) {
    if (!vis[sn[i]]) {
      dfs(sn[i]);
    }
  }
  int l = ans;
  map<int, int> indsol;
  for (int i = 0; i < l; i++) {
    indsol[sol[i]] = i;
  }
  for (int i = 0; i < l; i++) {
    vector<int> t = adj[sol[i]];
    for (auto j : t) {
      if (indsol[j] > i) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans << "\n";
  for (auto h : sol) {
    cout << h << " ";
  }
}
