#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> ma, v[maxn], r;
int n, k, m, a;
int vis[maxn];
int cnt, ff;
void dfs(int x) {
  if (vis[x] == 2) return;
  vis[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int to = v[x][i];
    if (vis[to] == 1) {
      cout << -1 << endl;
      exit(0);
    }
    dfs(to);
  }
  vis[x] = 2;
  r.push_back(x);
}
int main() {
  scanf("%d%d", &n, &k);
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < k; i++) {
    scanf("%d", &a);
    ma.push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &m);
    for (int j = 0; j < m; j++) {
      scanf("%d", &a);
      v[i].push_back(a);
    }
  }
  for (int i = 0; i < ma.size(); i++) {
    dfs(ma[i]);
  }
  int l = r.size();
  cout << l << endl;
  for (int i = 0; i < l - 1; i++) cout << r[i] << ' ';
  cout << r[l - 1] << endl;
  return 0;
}
