#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k, b[N], color[N], as;
vector<int> a[N];
vector<int> ans;
void dfs(int v) {
  color[v] = 1;
  for (int i = 0; i < a[v].size(); ++i) {
    if (!color[a[v][i]])
      dfs(a[v][i]);
    else if (color[a[v][i]] == 1) {
      as = -1;
      return;
    }
  }
  color[v] = 2;
  ans.push_back(v);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int c = 0;
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    for (int j = 1; j <= x; ++j) {
      int r;
      cin >> r;
      a[i].push_back(r);
    }
  }
  for (int i = 1; i <= k; ++i) {
    if (!color[b[i]]) dfs(b[i]);
  }
  if (as == -1) return cout << as, 0;
  cout << ans.size() << "\n";
  copy(ans.begin(), ans.end(), ostream_iterator<long long>(cout, " "));
}
