#include <bits/stdc++.h>
using namespace std;
int n, k, c[100000];
char color[100000];
vector<int> *V;
vector<int> ans;
void dfs_visit(int v) {
  color[v] = 'g';
  for (int i = 0; i < V[v].size(); i++) {
    int w = V[v][i];
    if (color[w] == 'g') {
      cout << -1 << endl;
      exit(0);
    }
    if (color[w] != 'b') dfs_visit(w);
  }
  color[v] = 'b';
  ans.push_back(v);
}
void dfs() {
  for (int i = 0; i < n; i++) color[i] = 'w';
  for (int i = 0; i < k; i++) {
    if (color[c[i]] == 'w') dfs_visit(c[i]);
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> c[i];
    c[i]--;
  }
  V = new vector<int>[n];
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    for (int j = 0; j < t; j++) {
      int co;
      cin >> co;
      co--;
      V[i].push_back(co);
    }
  }
  dfs();
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
  cout << endl;
  return 0;
}
