#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int> adj[100005];
int vis[100005];
void dfs(int k) {
  vis[k] = 1;
  for (auto it : adj[k]) {
    if (vis[it] == 1) {
      cout << "-1" << endl;
      exit(0);
    }
    if (vis[it] == 0) {
      dfs(it);
    }
  }
  v.push_back(k);
  vis[k] = 2;
}
int main() {
  int n, k;
  cin >> n >> k;
  int arr[k];
  for (int i = 0; i < k; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    int len;
    cin >> len;
    for (int j = 0; j < len; j++) {
      int x;
      cin >> x;
      adj[i].push_back(x);
    }
  }
  for (int i = 0; i < k; i++) {
    if (!vis[arr[i]]) dfs(arr[i]);
  }
  cout << v.size() << endl;
  for (auto it : v) cout << it << " ";
}
