#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], t[N];
vector<int> G[N], ans;
int used[N];
void dfs(int v) {
  used[v] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (used[u] == 1) {
      cout << -1 << endl;
      exit(0);
    }
    if (used[u]) continue;
    dfs(u);
  }
  ans.push_back(v);
  used[v] = 2;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    for (int j = 0; j < t[i]; j++) {
      int c;
      cin >> c;
      G[i].push_back(c);
    }
  }
  for (int i = 1; i <= k; i++) {
    if (!used[a[i]]) dfs(a[i]);
  }
  cout << ans.size() << endl;
  for (int i : ans) cout << i << " ";
  cout << endl;
  return 0;
}
