#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > mp, mp1;
map<int, int> mpo;
vector<int> v, c;
map<int, pair<int, int> > mm;
int n, k, i, cnt = 0, uu;
bool visit[100004] = {false}, visit1[100005] = {false};
int white = 0, gray = 1, black = 2;
void DFS(int node) {
  visit[node] = true;
  for (int j = 0; j < mp[node].size(); j++) {
    int child = mp[node][j];
    if (!visit[child]) DFS(child);
  }
  if (!visit1[node]) c.push_back(node + 1);
  visit1[node] = true;
}
bool DFSUTIL(int node, int color[]) {
  color[node] = gray;
  for (int q = 0; q < mp[node].size(); q++) {
    int x = mp[node][q];
    if (color[x] == gray) return true;
    if (color[x] == white && DFSUTIL(x, color)) return true;
  }
  color[node] = black;
  return false;
}
bool iscycle() {
  int color[100007];
  memset(color, white, sizeof(color));
  for (int j = 0; j < k; j++) {
    if (color[v[j]] == white)
      if (DFSUTIL(v[j], color)) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (i = 0; i < k; i++) {
    int y;
    cin >> y;
    v.push_back(y - 1);
  }
  for (i = 0; i < n; i++) {
    int y;
    cin >> y;
    for (int j = 0; j < y; j++) {
      int u;
      cin >> u;
      mp[i].push_back(u - 1);
    }
  }
  if (iscycle()) return cout << -1, 0;
  for (i = 0; i < v.size(); i++) DFS(v[i]);
  cout << c.size() << '\n';
  for (i = 0; i < c.size(); i++) cout << c[i] << ' ';
  return 0;
}
