#include <bits/stdc++.h>
using namespace std;
int n, k;
map<int, vector<int> > cours;
map<int, bool> check;
vector<int> way;
vector<int> out;
bool ans(int m) {
  if ((check[m] == false) &&
      (way.size() == 0 || find(way.begin(), way.end(), m) == way.end())) {
    way.push_back(m);
    for (int i = 0; i < cours[m].size(); i++) {
      if (!ans(cours[m][i])) return false;
    }
    way.pop_back();
    check[m] = true;
    out.push_back(m);
    return true;
  } else if (check[m] == false)
    return false;
  else
    return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  vector<int> mn;
  for (int i = 0; i < k; i++) {
    int temp;
    cin >> temp;
    mn.push_back(temp);
  }
  int nulls = 0;
  for (int i = 1; i <= n; i++) {
    int tmp_n;
    cin >> tmp_n;
    if (tmp_n == 0) nulls++;
    for (int j = 0; j < tmp_n; j++) {
      int tmp;
      cin >> tmp;
      cours[i].push_back(tmp);
      check[i] = false;
    }
  }
  if (nulls == 0) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < mn.size(); i++) {
    if (!ans(mn[i])) {
      cout << -1;
      return 0;
    }
  }
  cout << out.size() << endl;
  for (int i = 0; i < out.size(); i++) cout << out[i] << ' ';
  return 0;
}
