#include <bits/stdc++.h>
using namespace std;
const unsigned int mod = 1e9 + 7;
const int mx = 100005;
int cycle, n, k;
int color[mx];
int ar[mx];
vector<int> g[mx];
vector<int> ord;
void dfs(int u) {
  if (color[u] == 0) {
    color[u] = 1;
    for (int to : g[u]) dfs(to);
    color[u] = 2;
    ord.push_back(u);
  } else if (color[u] == 1)
    cycle = 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (long long int(i) = (1); (i) <= (k); ++(i)) cin >> ar[i];
  for (long long int(i) = (1); (i) <= (n); ++(i)) {
    int t;
    cin >> t;
    for (long long int(j) = (1); (j) <= (t); ++(j)) {
      int x;
      cin >> x;
      g[i].push_back(x);
    }
  }
  for (int i = 1; i <= k; ++i) dfs(ar[i]);
  if (cycle)
    cout << -1 << '\n';
  else {
    cout << ord.size() << '\n';
    for (long long int(i) = 0; (i) < (ord.size()); ++(i)) cout << ord[i] << " ";
  }
  return 0;
}
