#include <bits/stdc++.h>
using namespace std;
const int nMax = 1e5 + 2;
vector<int> color(nMax, (int)0), var, ans, need[nMax];
inline void dfs(int v) {
  color[v] = 1;
  for (int i = 0; i < (int)need[v].size(); i++) {
    int to = need[v][i];
    if (color[to] == 1) {
      printf("-1");
      exit(0);
    } else if (color[to] == 0)
      dfs(to);
  }
  color[v] = 2;
  ans.push_back(v);
}
signed main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    var.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    for (int j = 0; j < t; j++) {
      int u;
      scanf("%d", &u);
      need[i].push_back(u - 1);
    }
  }
  for (int i = 0; i < k; i++) {
    if (color[var[i] - 1] == 0) dfs(var[i] - 1);
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); i++) printf("%d ", ++ans[i]);
  return 0;
}
