#include <bits/stdc++.h>
using namespace std;
vector<long long> b[1000001];
vector<long long> vis(1e6, 0);
vector<long long> cc[10000001];
long long pose = 0;
void dfs(long long v, long long t) {
  if (vis[v] == 1) {
    pose = 1;
  }
  if (vis[v]) return;
  vis[v] = 1;
  for (auto u : b[v]) {
    dfs(u, t);
  }
  vis[v] = 2;
  cc[t].push_back(v);
}
int main() {
  long long i, j, k, l;
  long long x, y, z;
  long long n;
  long long flag = 0;
  cin >> n;
  cin >> k;
  vector<long long> a(k);
  vector<long long> ans(n + 1);
  for (i = 0; i < k; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= n; i++) {
    cin >> x;
    for (j = 0; j < x; j++) {
      cin >> y;
      b[i].push_back(y);
    }
  }
  l = 0;
  for (i = 0; i < k; i++) dfs(a[i], a[i]);
  for (i = 0; i < k; i++) {
    for (j = 0; j < cc[a[i]].size(); j++) {
      ans[l] = cc[a[i]][j];
      l++;
    }
  }
  if (pose == 1)
    cout << "-1";
  else {
    cout << l << endl;
    for (i = 0; i < l; i++) cout << ans[i] << " ";
  }
  return 0;
}
