#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
long long a[MAXN], b[MAXN];
long long n, y, z, t, m, f, x, d = 1, c, g[MAXN], k;
vector<int> v[MAXN], h;
bool mark[MAXN], mark1[MAXN], io = false;
long long dfs(long long x) {
  g[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (g[v[x][i]] == 0) {
      k = dfs(v[x][i]);
      if (k == -1) {
        return -1;
      }
      if (g[v[x][i]] == 2) {
        b[d] = v[x][i];
        d++;
      }
    } else if (g[v[x][i]] == 1) {
      return -1;
    }
  }
  g[x] = 2;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cin >> x;
    for (int j = 1; j <= x; j++) {
      cin >> y;
      v[i].push_back(y);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (g[a[i]] == 0) {
      y = dfs(a[i]);
      if (g[a[i]] == 2) {
        b[d] = a[i];
        d++;
      }
      if (y == -1) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << d - 1 << endl;
  for (int i = 1; i < d; i++) {
    cout << b[i] << " ";
  }
  return 0;
}
