#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > G;
vector<char> color;
vector<int> ans;
vector<int> target;
void add(int a, int b) { G[a].push_back(b); }
bool DFS(int v) {
  bool res = true;
  color[v] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    if (color[G[v][i]] == 1) return false;
    if (color[G[v][i]] == 0) res &= DFS(G[v][i]);
  }
  color[v] = 2;
  ans.push_back(v);
  return res;
}
int main() {
  int N, K;
  cin >> N >> K;
  G.resize(N);
  target.resize(K, 0);
  color.resize(N, 0);
  ans.reserve(N);
  for (int i = 0; i < K; i++) {
    cin >> target[i];
    target[i]--;
  }
  for (int i = 0; i < N; i++) {
    int k, x;
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> x;
      add(i, x - 1);
    }
  }
  bool OK = true;
  for (int i = 0; i < K; i++)
    if (color[target[i]] == 0) OK &= DFS(target[i]);
  if (OK) {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << ' ';
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
