#include <bits/stdc++.h>
using namespace std;
vector<long long> v[100005];
long long vis[100005];
long long vis1[100005];
long long pos[100005];
long long low[100005];
long long num[100005];
long long comp[100005];
long long cont = 1, sol = 0;
vector<long long> order;
vector<long long> pila;
void tarjan(long long ini) {
  vis1[ini] = 1;
  low[ini] = num[ini] = cont++;
  pila.push_back(ini);
  for (int i = 0; i < v[ini].size(); i++) {
    long long vecino = v[ini][i];
    if (num[vecino] == -1) tarjan(vecino);
    if (vis1[vecino]) {
      low[ini] = min(low[ini], low[vecino]);
    }
  }
  if (low[ini] == num[ini]) {
    while (1) {
      long long aux = pila.back();
      pila.pop_back();
      vis1[aux] = 0;
      comp[aux] = sol;
      if (ini == aux) break;
    }
    sol++;
  }
}
void dfs(int ini) {
  vis[ini] = 1;
  for (int i = 0; i < v[ini].size(); i++) {
    long long vecino = v[ini][i];
    if (!vis[vecino]) dfs(vecino);
  }
  order.push_back(ini);
}
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> g;
  set<long long> ans;
  while (k--) {
    long long num;
    cin >> num;
    g.push_back(num);
  }
  memset(num, -1, sizeof(num));
  for (int i = 1; i <= n; i++) {
    long long num1;
    cin >> num1;
    while (num1 > 0) {
      long long a;
      cin >> a;
      v[i].push_back(a);
      num1--;
    }
  }
  for (int i = 0; i < g.size(); i++) {
    if (!vis[g[i]]) dfs(g[i]);
  }
  for (int i = 0; i < order.size(); i++) {
    if (num[order[i]] == -1) tarjan(order[i]);
  }
  for (int i = 0; i < order.size(); i++) {
    ans.insert(comp[order[i]]);
  }
  if (ans.size() != order.size()) {
    cout << -1;
    return 0;
  }
  cout << order.size() << endl;
  for (int i = 0; i < order.size(); i++) {
    cout << order[i] << " ";
  }
}
