#include <bits/stdc++.h>
const int MAXN = 100100;
using namespace std;
vector<int> g[MAXN];
int used[MAXN];
bool f;
vector<int> ans;
void dfs(int v) {
  used[v] = 1;
  for (auto u : g[v])
    if (!used[u])
      dfs(u);
    else if (used[u] == 1) {
      f = 1;
      return;
    }
  used[v] = 2;
  ans.push_back(v);
}
int main() {
  int c[MAXN];
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    for (int j = 0; j < t; ++j) {
      int x;
      cin >> x;
      g[i].push_back(--x);
    }
  }
  for (int i = 0; i < k; ++i) {
    if (!used[c[i] - 1]) dfs(c[i] - 1);
  }
  if (f) {
    cout << -1;
    return 0;
  }
  cout << ans.size() << endl;
  for (auto i : ans) cout << i + 1 << ' ';
}
