#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
vector<int> adj[100010];
vector<int> adj1[100010];
vector<int> vis(100010, 0);
set<int> c;
vector<int> topo, ans;
int flag = 0;
void dfs(int a) {
  vis[a] = 1;
  for (auto i : adj[a]) {
    if (vis[i] == 0) {
      dfs(i);
    } else if (vis[i] == 1) {
      flag = 1;
    }
  }
  vis[a] = 2;
  topo.push_back(a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (long long i = 0; i < k; i++) {
    int a;
    cin >> a;
    c.insert(a);
  }
  for (long long i = 0; i < n; i++) {
    int num;
    cin >> num;
    for (long long j = 0; j < num; j++) {
      int a;
      cin >> a;
      adj[i + 1].push_back(a);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0 && c.find(i) != c.end()) {
      dfs(i);
    }
  }
  if (flag == 1) {
    cout << -1 << '\n';
    return 0;
  }
  cout << (int)topo.size() << '\n';
  for (auto i : topo) {
    cout << i << " ";
  }
  cout << '\n';
}
