#include <bits/stdc++.h>
using namespace std;
vector<int> moc;
const int X = 1e5 + 10;
vector<int> D[X];
vector<int> ans;
bool v[X], go[X];
void dfs(int z) {
  v[z] = true;
  go[z] = true;
  for (int f : D[z]) {
    if (!v[f]) dfs(f);
    if (go[f]) {
      cout << "-1" << endl;
      exit(0);
    }
  }
  go[z] = false;
  ans.push_back(z);
}
int main() {
  int n, k;
  cin >> n >> k;
  while (k--) {
    int x;
    cin >> x;
    moc.push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    while (t--) {
      int a;
      cin >> a;
      D[i].emplace_back(a);
    }
  }
  for (int i : moc) {
    if (!v[i]) dfs(i);
  }
  cout << ans.size() << endl;
  cout << ans[0];
  for (int t = 1; t < (int)ans.size(); t++) cout << " " << ans[t];
  cout << endl;
  return 0;
}
