#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
int n, m, a[maxn], dep[maxn];
bool mark[maxn], vis[maxn];
vector<int> nex[maxn], ans;
void dfs(int x) {
  if (mark[x]) return;
  for (auto p : nex[x]) {
    if (vis[p]) {
      printf("-1");
      exit(0);
    }
    vis[p] = true;
    dfs(p);
    vis[p] = false;
  }
  if (!mark[x]) ans.push_back(x);
  mark[x] = true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    int w, x;
    scanf("%d", &w);
    while (w--) {
      scanf("%d", &x);
      nex[i].push_back(x);
    }
  }
  for (int i = 1; i <= m; ++i) {
    vis[a[i]] = true;
    dfs(a[i]);
    vis[a[i]] = false;
  }
  printf("%d\n", ans.size());
  for (auto p : ans) printf("%d ", p);
  return 0;
}
