#include <bits/stdc++.h>
using namespace std;
bool study(int x, vector<vector<int>>& cours, vector<char>& used,
           vector<int>& result) {
  if (used[x] == 2) return true;
  if (used[x] == 1) return false;
  used[x] = 1;
  for (auto y : cours[x])
    if (!study(y, cours, used, result)) return false;
  result.push_back(x);
  used[x] = 2;
  return true;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> need(k);
  for (int i = 0; i < k; ++i) {
    cin >> need[i];
    --need[i];
  }
  vector<vector<int>> cources(n);
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    cources[i].resize(t);
    for (int j = 0; j < t; ++j) {
      cin >> cources[i][j];
      --cources[i][j];
    }
  }
  vector<char> used(n, 0);
  vector<int> res;
  for (int i = 0; i < k; ++i) {
    if (!study(need[i], cources, used, res)) {
      cout << -1;
      return 0;
    }
  }
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); ++i) cout << res[i] + 1 << ' ';
}
