#include <bits/stdc++.h>
const long long mod = 1000000007;
const long long Inf = 2 * 1e9;
const long long p = 31;
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int n, k;
vector<int> q;
vector<vector<int>> a;
vector<int> ans, used, used2;
void dfs(int x) {
  if (used2[x]) return;
  if (used[x]) {
    cout << -1;
    exit(0);
  }
  used[x] = true;
  if (a[x].size() == 0) {
    used2[x] = true;
    ans.push_back(x);
    return;
  }
  for (int(i) = 0; (i) < a[x].size(); (i)++) {
    int to = a[x][i];
    dfs(to);
  }
  ans.push_back(x);
  used2[x] = true;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  q.resize(k + 1);
  used.resize(n + 1, 0);
  used2.resize(n + 1, 0);
  a.resize(n + 1);
  for (int(i) = 0; (i) < k; (i)++) cin >> q[i];
  for (int(i) = 1; (i) < n + 1; (i)++) {
    int sz;
    cin >> sz;
    a[i].resize(sz);
    for (int(j) = 0; (j) < sz; (j)++) cin >> a[i][j];
  }
  for (int(i) = 0; (i) < k; (i)++) {
    dfs(q[i]);
  }
  cout << ans.size() << endl;
  for (int(i) = 0; (i) < ans.size(); (i)++) {
    cout << ans[i] << " ";
  }
  return 0;
}
