#include <bits/stdc++.h>
using namespace std;
int n, k, y;
vector<int> a(100010);
vector<bool> vi(100010), rs(100010);
vector<int> v[100010], ans;
bool dfs(int x) {
  vi[x] = rs[x] = 1;
  for (auto e : v[x]) {
    if (!vi[e] && dfs(e))
      return 1;
    else if (rs[e])
      return 1;
  }
  ans.push_back(x);
  rs[x] = 0;
  return 0;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    int tt;
    scanf("%d", &tt);
    while (tt--) {
      scanf("%d", &y);
      v[i].push_back(y);
    }
  }
  for (int i = 0; i < k; ++i) {
    if (!vi[a[i]]) {
      if (dfs(a[i])) {
        puts("-1");
        return 0;
      }
    }
  }
  printf("%d\n", ans.size());
  for (auto e : ans) printf("%d ", e);
  printf("\n");
  return 0;
}
