#include <bits/stdc++.h>
using namespace std;
long long int n, k;
vector<long long int> ExamsDeneHaiJo;
unordered_map<long long int, list<long long int> > h;
vector<long long int> ans;
long long int visited[100005] = {0};
bool isCyclic = false;
void tps(long long int node) {
  if (visited[node] == 2) return;
  visited[node] = 1;
  for (auto children : h[node]) {
    if (visited[children] == 1) {
      isCyclic = true;
      return;
    }
    tps(children);
  }
  visited[node] = 2;
  ans.push_back(node);
}
void dfs() {
  for (auto node : ExamsDeneHaiJo) {
    tps(node);
    if (isCyclic) break;
  }
  if (isCyclic) {
    cout << "-1" << endl;
    return;
  }
  cout << ans.size() << endl;
  for (auto node : ans) {
    cout << node << " ";
  }
  cout << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (long long int i = 0; i < k; i++) {
    long long int x;
    cin >> x;
    ExamsDeneHaiJo.push_back(x);
  }
  for (long long int u = 1; u <= n; u++) {
    long long int m;
    cin >> m;
    if (m == 0) continue;
    for (long long int j = 0; j < m; j++) {
      long long int v;
      cin >> v;
      h[u].push_back(v);
    }
  }
  dfs();
  return 0;
}
