#include <bits/stdc++.h>
using namespace std;
bool f = 0;
vector<int> p, q, r;
void dfs(vector<vector<int>>& v, int u) {
  int i, k;
  r[u] = 1;
  p[u] = 1;
  for (i = 0; i < v[u].size(); i++) {
    k = v[u][i];
    if (r[k] == 1) {
      f = 1;
      return;
    }
    if (p[k] == 0) dfs(v, k);
  }
  q.push_back(u);
  r[u] = 0;
}
int main() {
  int n, k, i, x, j, y;
  cin >> n >> k;
  int b[k];
  for (i = 0; i < k; i++) cin >> b[i];
  for (i = 0; i <= n; i++) r.push_back(0);
  vector<vector<int>> v(n + 1);
  for (i = 1; i <= n; i++) {
    cin >> x;
    for (j = 0; j < x; j++) {
      cin >> y;
      v[i].push_back(y);
    }
  }
  for (i = 0; i <= n; i++) p.push_back(0);
  for (i = 0; i < k; i++)
    if (p[b[i]] == 0) {
      dfs(v, b[i]);
      if (f == 1) break;
    }
  if (f == 1)
    cout << -1;
  else {
    cout << q.size() << endl;
    for (i = 0; i < q.size(); i++) cout << q[i] << " ";
  }
}
