#include <bits/stdc++.h>
using namespace std;
vector<int> runner;
vector<vector<int>> all;
vector<int> res;
void course(int v) {
  runner[v] = 1;
  for (int& x : all[v]) {
    if (!runner[x])
      course(x);
    else if (runner[x] == 1) {
      cout << -1, exit(0);
    }
  }
  runner[v] = 2;
  res.push_back(v);
  return;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> lst(k);
  all.resize(n);
  runner.resize(n);
  for (int i = 0; i < k; i++) {
    cin >> lst[i];
    lst[i]--;
  }
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int p;
      cin >> p;
      all[i].push_back(p - 1);
    }
  }
  for (int& x : lst) {
    if (!runner[x]) course(x);
  }
  cout << res.size() << endl;
  for (int& x : res) {
    cout << x + 1 << ' ';
  }
}
