#include <bits/stdc++.h>
using namespace std;
vector<vector<long> > a(100500);
vector<long> v(100500, 0), ans;
void dfs(long p) {
  if (v[p] == 1) {
    cout << -1;
    exit(0);
  }
  if (v[p] == 2) return;
  v[p] = 1;
  for (long i = 0; i < a[p].size(); i++) dfs(a[p][i]);
  ans.push_back(p);
  v[p] = 2;
}
int main() {
  long n, k;
  vector<long> s;
  cin >> k >> n;
  for (long i = 0; i < n; i++) {
    long x;
    cin >> x;
    s.push_back(x);
  }
  for (long i = 1; i <= k; i++) {
    long l;
    cin >> l;
    if (l)
      for (long j = 0; j < l; j++) {
        long x;
        cin >> x;
        a[i].push_back(x);
      }
  }
  for (long i = 0; i < n; i++) dfs(s[i]);
  cout << ans.size() << endl;
  for (long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
