#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int N = 1e5 + 10;
vector<set<int>> vertices;
set<int> mainCourses;
bool visited[100010];
vector<int> topsort;
bool isGood = 1;
int color[N];
void dfs(int u) {
  visited[u] = 1;
  if (color[u] == 0) {
    color[u] = 1;
    for (auto it : vertices[u]) {
      dfs(it);
    }
    topsort.push_back(u);
    color[u] = 2;
  } else if (color[u] == 1)
    isGood = 0;
}
int main() {
  int n, k;
  cin >> n >> k;
  vertices.resize(n + 1);
  for (int i = 0; i < k; i++) {
    int u;
    cin >> u;
    mainCourses.insert(u);
  }
  for (int i = 1; i <= n; i++) {
    int u;
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> u;
      vertices[i].insert(u);
    }
  }
  for (auto it : mainCourses) {
    if (!visited[it]) {
      isGood = 1;
      dfs(it);
      if (!isGood) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << (int)topsort.size() << endl;
  for (auto it : topsort) {
    cout << it << " ";
  }
}
