#include <bits/stdc++.h>
using namespace std;
int to[100010];
int edge;
int Next[100010];
int pre[100010];
void addEdge(int x, int y) {
  to[++edge] = y;
  Next[edge] = pre[x];
  pre[x] = edge;
}
int a[100010];
int vis[100010];
vector<int> ans;
int dfs(int x) {
  vis[x] = -1;
  for (int i = pre[x]; i; i = Next[i]) {
    int v = to[i];
    if (vis[v] == -1) return 0;
    if (!vis[v] && !dfs(v)) return 0;
  }
  vis[x] = 1;
  ans.push_back(x);
  return 1;
}
int main() {
  int n, k, i, x, j, u;
  edge = 0;
  cin >> n >> k;
  for (i = 1; i <= k; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    cin >> x;
    for (j = 1; j <= x; j++) {
      cin >> u;
      addEdge(i, u);
    }
  }
  for (i = 1; i <= k; i++) {
    if (!vis[a[i]] && !dfs(a[i])) {
      cout << -1;
      return 0;
    }
  }
  cout << ans.size() << endl;
  for (auto it : ans) cout << it << " ";
}
