#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, MAXN = 1e5 + 10;
vector<int> ans;
vector<int> g[MAXN];
short int used[MAXN];
int a[MAXN];
int k, n;
void dfs(int v) {
  used[v] = 1;
  for (auto to : g[v]) {
    if (used[to] == 1) {
      cout << "-1";
      exit(0);
    }
    if (used[to] == 0) dfs(to);
  }
  ans.push_back(v);
  used[v] = 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    int x, m;
    cin >> m;
    for (int j = 1; j <= m; ++j) {
      cin >> x;
      g[i].push_back(x);
    }
  }
  for (int i = 1; i <= k; ++i)
    if (used[a[i]] == 0) dfs(a[i]);
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x << " ";
  return 0;
}
