#include <bits/stdc++.h>
using namespace std;
int n, k, c[100005], visit[100005], tp = 0;
vector<int> a[100005], ans;
bool ok[100005];
void dfs(int u) {
  visit[u] = tp;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i];
    if (ok[v]) continue;
    if (visit[v] == tp) {
      cout << -1;
      exit(0);
    } else
      dfs(v);
  }
  ans.push_back(u);
  ok[u] = 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= k; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    while (t--) {
      int u;
      cin >> u;
      a[i].push_back(u);
    }
  }
  for (int i = 1; i <= k; i++) {
    if (!visit[c[i]]) {
      tp++;
      dfs(c[i]);
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
