#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g(0, vector<int>());
vector<int> color;
vector<int> curse;
bool cycle = false;
void dfs(int v) {
  if (color[v] == 0) {
    color[v] = 1;
    for (size_t i = 0; i < g[v].size(); i++) dfs(g[v][i]);
    color[v] = 2;
    curse.push_back(v);
  } else if (color[v] == 1)
    cycle = true;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> main_curse(k);
  for (int i = 0; i < k; i++) {
    cin >> main_curse[i];
    main_curse[i]--;
  }
  g.resize(n);
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int p;
      cin >> p;
      g[i].push_back(--p);
    }
  }
  color.resize(n);
  for (int i = 0; i < k; i++) {
    if (color[main_curse[i]] == 0) {
      dfs(main_curse[i]);
    }
  }
  if (cycle)
    cout << -1;
  else {
    cout << curse.size() << endl;
    for (int i = 0; i < curse.size(); i++) {
      cout << ++curse[i] << " ";
    }
  }
}
