#include <bits/stdc++.h>
using namespace std;
vector<int> ans(0);
void dfs(int v, vector<vector<int>> &g, vector<int> &used) {
  if (used[v]) return;
  used[v] = 1;
  for (auto it : g[v]) {
    if (used[it] == 1) {
      cout << -1;
      exit(0);
    } else if (used[it] == 0) {
      dfs(it, g, used);
    }
  }
  used[v] = 2;
  ans.push_back(v);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> g(n, vector<int>(0, 0));
  vector<int> used(n, 0);
  vector<int> mc(k);
  for (auto &it : mc) {
    cin >> it;
  }
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    for (int j = 0; j < t; j++) {
      int tmp;
      cin >> tmp;
      g[i].push_back(--tmp);
    }
  }
  for (int i = 0; i < mc.size(); i++) dfs(mc[i] - 1, g, used);
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it + 1 << ' ';
  }
}
