#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
int n;
int m;
int t;
int x;
int y;
int a[N];
int used[N];
vector<int> res;
vector<int> g[N];
void dfs(int v, int p) {
  used[v] = 2;
  for (auto x : g[v]) {
    if (used[x] == 0) {
      dfs(x, v);
    }
    if (used[x] == 2) {
      cout << -1;
      exit(0);
    }
  }
  used[v] = 1;
  res.push_back(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t;
    while (t--) {
      cin >> x;
      g[i].push_back(x);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!used[a[i]]) {
      dfs(a[i], -1);
    }
  }
  cout << (int)res.size() << "\n";
  for (auto x : res) {
    cout << x << " ";
  }
}
