#include <bits/stdc++.h>
using namespace std;
const int maxv = 1e5 + 100;
vector<int> G[maxv];
int v, k, a, b;
int color[maxv];
vector<int> mc;
vector<int> ans;
void dfs(int u) {
  if (color[u] == 0) {
    color[u] = 1;
    for (auto to : G[u]) dfs(to);
    color[u] = 2;
    ans.push_back(u);
  } else if (color[u] == 1) {
    puts("-1");
    exit(0);
  }
}
int main() {
  scanf("%d%d", &v, &k);
  for (int i = 0; i < k; ++i) {
    scanf("%d", &a);
    mc.push_back(a);
  }
  for (int i = 1; i <= v; ++i) {
    scanf("%d", &a);
    for (int j = 0; j < a; ++j) {
      scanf("%d", &b);
      G[i].push_back(b);
    }
  }
  for (auto i : mc) dfs(i);
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d ", i);
  return 0;
}
