#include <bits/stdc++.h>
using namespace std;
long double EPS = 1e-9;
long long cel(long long a, long long b) { return ((a - 1) / b + 1); }
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return (b == 0) ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long po(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) {
      ans = (ans * x) % 1000000007;
    }
    y >>= 1;
    x = (x * x) % 1000000007;
  }
  return ans;
}
const int N = 100001;
vector<int> vis(N, 0), pus(N, 0), ans;
bool ok = true;
vector<int> adj[N];
void dfs(int u) {
  if (vis[u] == 1 && (pus[u] != 1)) {
    ok = false;
    return;
  }
  if (pus[u] == 1) {
    return;
  }
  vis[u] = 1;
  for (int t : adj[u]) {
    dfs(t);
  }
  ans.push_back(u);
  pus[u] = 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, t, x, y, m, k;
  cin >> n >> k;
  vector<int> chk(k);
  for (int i = 0; i < k; i++) {
    cin >> chk[i];
  }
  for (int i = 1; i < n + 1; i++) {
    cin >> x;
    for (int j = 0; j < x; j++) {
      cin >> y;
      adj[i].push_back(y);
    }
  }
  for (int i = 0; i < k; i++) {
    dfs(chk[i]);
    if (!ok) {
      break;
    }
  }
  if (!ok)
    cout << -1;
  else {
    cout << ans.size() << "\n";
    for (int t : ans) cout << t << " ";
  }
  return 0;
}
