#include <bits/stdc++.h>
const int MAXN = 100000 + 1;
int major[MAXN], color[MAXN];
std::vector<int> adj[MAXN], ans;
void dfs(int u) {
  if (color[u] == 1) {
    puts("-1");
    exit(EXIT_SUCCESS);
  }
  if (color[u] == 2) return;
  color[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) dfs(adj[u][i]);
  color[u] = 2;
  ans.push_back(u);
}
int main(int argc, char *argv[]) {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &major[i]);
  }
  for (int i = 1; i <= n; i++) {
    int t, x;
    scanf("%d", &t);
    while (t--) {
      scanf("%d", &x);
      adj[i].push_back(x);
    }
  }
  for (int i = 1; i <= k; i++) dfs(major[i]);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
  }
  return 0;
}
